Initial commit
This commit is contained in:
		
							
								
								
									
										6
									
								
								system/.htaccess
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								system/.htaccess
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
<IfModule authz_core_module>
 | 
			
		||||
	Require all denied
 | 
			
		||||
</IfModule>
 | 
			
		||||
<IfModule !authz_core_module>
 | 
			
		||||
	Deny from all
 | 
			
		||||
</IfModule>
 | 
			
		||||
							
								
								
									
										134
									
								
								system/core/Benchmark.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								system/core/Benchmark.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,134 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Benchmark Class
 | 
			
		||||
 *
 | 
			
		||||
 * This class enables you to mark points and calculate the time difference
 | 
			
		||||
 * between them. Memory consumption can also be displayed.
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Libraries
 | 
			
		||||
 * @category	Libraries
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/libraries/benchmark.html
 | 
			
		||||
 */
 | 
			
		||||
class CI_Benchmark {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List of all benchmark markers
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	public $marker = array();
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Set a benchmark marker
 | 
			
		||||
	 *
 | 
			
		||||
	 * Multiple calls to this function can be made so that several
 | 
			
		||||
	 * execution points can be timed.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$name	Marker name
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function mark($name)
 | 
			
		||||
	{
 | 
			
		||||
		$this->marker[$name] = microtime(TRUE);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Elapsed time
 | 
			
		||||
	 *
 | 
			
		||||
	 * Calculates the time difference between two marked points.
 | 
			
		||||
	 *
 | 
			
		||||
	 * If the first parameter is empty this function instead returns the
 | 
			
		||||
	 * {elapsed_time} pseudo-variable. This permits the full system
 | 
			
		||||
	 * execution time to be shown in a template. The output class will
 | 
			
		||||
	 * swap the real value for this variable.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$point1		A particular marked point
 | 
			
		||||
	 * @param	string	$point2		A particular marked point
 | 
			
		||||
	 * @param	int	$decimals	Number of decimal places
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	string	Calculated elapsed time on success,
 | 
			
		||||
	 *			an '{elapsed_string}' if $point1 is empty
 | 
			
		||||
	 *			or an empty string if $point1 is not found.
 | 
			
		||||
	 */
 | 
			
		||||
	public function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
 | 
			
		||||
	{
 | 
			
		||||
		if ($point1 === '')
 | 
			
		||||
		{
 | 
			
		||||
			return '{elapsed_time}';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! isset($this->marker[$point1]))
 | 
			
		||||
		{
 | 
			
		||||
			return '';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! isset($this->marker[$point2]))
 | 
			
		||||
		{
 | 
			
		||||
			$this->marker[$point2] = microtime(TRUE);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return number_format($this->marker[$point2] - $this->marker[$point1], $decimals);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Memory Usage
 | 
			
		||||
	 *
 | 
			
		||||
	 * Simply returns the {memory_usage} marker.
 | 
			
		||||
	 *
 | 
			
		||||
	 * This permits it to be put it anywhere in a template
 | 
			
		||||
	 * without the memory being calculated until the end.
 | 
			
		||||
	 * The output class will swap the real value for this variable.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	string	'{memory_usage}'
 | 
			
		||||
	 */
 | 
			
		||||
	public function memory_usage()
 | 
			
		||||
	{
 | 
			
		||||
		return '{memory_usage}';
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										560
									
								
								system/core/CodeIgniter.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										560
									
								
								system/core/CodeIgniter.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										849
									
								
								system/core/Common.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										849
									
								
								system/core/Common.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										380
									
								
								system/core/Config.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										380
									
								
								system/core/Config.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,380 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Config Class
 | 
			
		||||
 *
 | 
			
		||||
 * This class contains functions that enable config files to be managed
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Libraries
 | 
			
		||||
 * @category	Libraries
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/libraries/config.html
 | 
			
		||||
 */
 | 
			
		||||
class CI_Config {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List of all loaded config values
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	public $config = array();
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List of all loaded config files
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	public $is_loaded =	array();
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List of paths to search when trying to load a config file.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @used-by	CI_Loader
 | 
			
		||||
	 * @var		array
 | 
			
		||||
	 */
 | 
			
		||||
	public $_config_paths =	array(APPPATH);
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Class constructor
 | 
			
		||||
	 *
 | 
			
		||||
	 * Sets the $config data from the primary config.php file as a class variable.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct()
 | 
			
		||||
	{
 | 
			
		||||
		$this->config =& get_config();
 | 
			
		||||
 | 
			
		||||
		// Set the base_url automatically if none was provided
 | 
			
		||||
		if (empty($this->config['base_url']))
 | 
			
		||||
		{
 | 
			
		||||
			if (isset($_SERVER['SERVER_ADDR']))
 | 
			
		||||
			{
 | 
			
		||||
				if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE)
 | 
			
		||||
				{
 | 
			
		||||
					$server_addr = '['.$_SERVER['SERVER_ADDR'].']';
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					$server_addr = $_SERVER['SERVER_ADDR'];
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				$base_url = (is_https() ? 'https' : 'http').'://'.$server_addr
 | 
			
		||||
					.substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				$base_url = 'http://localhost/';
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$this->set_item('base_url', $base_url);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log_message('info', 'Config Class Initialized');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Load Config File
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$file			Configuration file name
 | 
			
		||||
	 * @param	bool	$use_sections		Whether configuration values should be loaded into their own section
 | 
			
		||||
	 * @param	bool	$fail_gracefully	Whether to just return FALSE or display an error message
 | 
			
		||||
	 * @return	bool	TRUE if the file was loaded correctly or FALSE on failure
 | 
			
		||||
	 */
 | 
			
		||||
	public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
 | 
			
		||||
	{
 | 
			
		||||
		$file = ($file === '') ? 'config' : str_replace('.php', '', $file);
 | 
			
		||||
		$loaded = FALSE;
 | 
			
		||||
 | 
			
		||||
		foreach ($this->_config_paths as $path)
 | 
			
		||||
		{
 | 
			
		||||
			foreach (array($file, ENVIRONMENT.DIRECTORY_SEPARATOR.$file) as $location)
 | 
			
		||||
			{
 | 
			
		||||
				$file_path = $path.'config/'.$location.'.php';
 | 
			
		||||
				if (in_array($file_path, $this->is_loaded, TRUE))
 | 
			
		||||
				{
 | 
			
		||||
					return TRUE;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if ( ! file_exists($file_path))
 | 
			
		||||
				{
 | 
			
		||||
					continue;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				include($file_path);
 | 
			
		||||
 | 
			
		||||
				if ( ! isset($config) OR ! is_array($config))
 | 
			
		||||
				{
 | 
			
		||||
					if ($fail_gracefully === TRUE)
 | 
			
		||||
					{
 | 
			
		||||
						return FALSE;
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				if ($use_sections === TRUE)
 | 
			
		||||
				{
 | 
			
		||||
					$this->config[$file] = isset($this->config[$file])
 | 
			
		||||
						? array_merge($this->config[$file], $config)
 | 
			
		||||
						: $config;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					$this->config = array_merge($this->config, $config);
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				$this->is_loaded[] = $file_path;
 | 
			
		||||
				$config = NULL;
 | 
			
		||||
				$loaded = TRUE;
 | 
			
		||||
				log_message('debug', 'Config file loaded: '.$file_path);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($loaded === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			return TRUE;
 | 
			
		||||
		}
 | 
			
		||||
		elseif ($fail_gracefully === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		show_error('The configuration file '.$file.'.php does not exist.');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Fetch a config file item
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$item	Config item name
 | 
			
		||||
	 * @param	string	$index	Index name
 | 
			
		||||
	 * @return	string|null	The configuration item or NULL if the item doesn't exist
 | 
			
		||||
	 */
 | 
			
		||||
	public function item($item, $index = '')
 | 
			
		||||
	{
 | 
			
		||||
		if ($index == '')
 | 
			
		||||
		{
 | 
			
		||||
			return isset($this->config[$item]) ? $this->config[$item] : NULL;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Fetch a config file item with slash appended (if not empty)
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string		$item	Config item name
 | 
			
		||||
	 * @return	string|null	The configuration item or NULL if the item doesn't exist
 | 
			
		||||
	 */
 | 
			
		||||
	public function slash_item($item)
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! isset($this->config[$item]))
 | 
			
		||||
		{
 | 
			
		||||
			return NULL;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (trim($this->config[$item]) === '')
 | 
			
		||||
		{
 | 
			
		||||
			return '';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return rtrim($this->config[$item], '/').'/';
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Site URL
 | 
			
		||||
	 *
 | 
			
		||||
	 * Returns base_url . index_page [. uri_string]
 | 
			
		||||
	 *
 | 
			
		||||
	 * @uses	CI_Config::_uri_string()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string|string[]	$uri	URI string or an array of segments
 | 
			
		||||
	 * @param	string	$protocol
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	public function site_url($uri = '', $protocol = NULL)
 | 
			
		||||
	{
 | 
			
		||||
		$base_url = $this->slash_item('base_url');
 | 
			
		||||
 | 
			
		||||
		if (isset($protocol))
 | 
			
		||||
		{
 | 
			
		||||
			// For protocol-relative links
 | 
			
		||||
			if ($protocol === '')
 | 
			
		||||
			{
 | 
			
		||||
				$base_url = substr($base_url, strpos($base_url, '//'));
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (empty($uri))
 | 
			
		||||
		{
 | 
			
		||||
			return $base_url.$this->item('index_page');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$uri = $this->_uri_string($uri);
 | 
			
		||||
 | 
			
		||||
		if ($this->item('enable_query_strings') === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			$suffix = isset($this->config['url_suffix']) ? $this->config['url_suffix'] : '';
 | 
			
		||||
 | 
			
		||||
			if ($suffix !== '')
 | 
			
		||||
			{
 | 
			
		||||
				if (($offset = strpos($uri, '?')) !== FALSE)
 | 
			
		||||
				{
 | 
			
		||||
					$uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset);
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					$uri .= $suffix;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return $base_url.$this->slash_item('index_page').$uri;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (strpos($uri, '?') === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			$uri = '?'.$uri;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $base_url.$this->item('index_page').$uri;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Base URL
 | 
			
		||||
	 *
 | 
			
		||||
	 * Returns base_url [. uri_string]
 | 
			
		||||
	 *
 | 
			
		||||
	 * @uses	CI_Config::_uri_string()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string|string[]	$uri	URI string or an array of segments
 | 
			
		||||
	 * @param	string	$protocol
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	public function base_url($uri = '', $protocol = NULL)
 | 
			
		||||
	{
 | 
			
		||||
		$base_url = $this->slash_item('base_url');
 | 
			
		||||
 | 
			
		||||
		if (isset($protocol))
 | 
			
		||||
		{
 | 
			
		||||
			// For protocol-relative links
 | 
			
		||||
			if ($protocol === '')
 | 
			
		||||
			{
 | 
			
		||||
				$base_url = substr($base_url, strpos($base_url, '//'));
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $base_url.$this->_uri_string($uri);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// -------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Build URI string
 | 
			
		||||
	 *
 | 
			
		||||
	 * @used-by	CI_Config::site_url()
 | 
			
		||||
	 * @used-by	CI_Config::base_url()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string|string[]	$uri	URI string or an array of segments
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _uri_string($uri)
 | 
			
		||||
	{
 | 
			
		||||
		if ($this->item('enable_query_strings') === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			is_array($uri) && $uri = implode('/', $uri);
 | 
			
		||||
			return ltrim($uri, '/');
 | 
			
		||||
		}
 | 
			
		||||
		elseif (is_array($uri))
 | 
			
		||||
		{
 | 
			
		||||
			return http_build_query($uri);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $uri;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * System URL
 | 
			
		||||
	 *
 | 
			
		||||
	 * @deprecated	3.0.0	Encourages insecure practices
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	public function system_url()
 | 
			
		||||
	{
 | 
			
		||||
		$x = explode('/', preg_replace('|/*(.+?)/*$|', '\\1', BASEPATH));
 | 
			
		||||
		return $this->slash_item('base_url').end($x).'/';
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Set a config file item
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$item	Config item key
 | 
			
		||||
	 * @param	string	$value	Config item value
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function set_item($item, $value)
 | 
			
		||||
	{
 | 
			
		||||
		$this->config[$item] = $value;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										104
									
								
								system/core/Controller.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								system/core/Controller.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,104 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Application Controller Class
 | 
			
		||||
 *
 | 
			
		||||
 * This class object is the super class that every library in
 | 
			
		||||
 * CodeIgniter will be assigned to.
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Libraries
 | 
			
		||||
 * @category	Libraries
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/general/controllers.html
 | 
			
		||||
 */
 | 
			
		||||
class CI_Controller {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Reference to the CI singleton
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	object
 | 
			
		||||
	 */
 | 
			
		||||
	private static $instance;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * CI_Loader
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	CI_Loader
 | 
			
		||||
	 */
 | 
			
		||||
	public $load;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Class constructor
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct()
 | 
			
		||||
	{
 | 
			
		||||
		self::$instance =& $this;
 | 
			
		||||
 | 
			
		||||
		// Assign all the class objects that were instantiated by the
 | 
			
		||||
		// bootstrap file (CodeIgniter.php) to local class variables
 | 
			
		||||
		// so that CI can run as one big super object.
 | 
			
		||||
		foreach (is_loaded() as $var => $class)
 | 
			
		||||
		{
 | 
			
		||||
			$this->$var =& load_class($class);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->load =& load_class('Loader', 'core');
 | 
			
		||||
		$this->load->initialize();
 | 
			
		||||
		log_message('info', 'Controller Class Initialized');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get the CI singleton
 | 
			
		||||
	 *
 | 
			
		||||
	 * @static
 | 
			
		||||
	 * @return	object
 | 
			
		||||
	 */
 | 
			
		||||
	public static function &get_instance()
 | 
			
		||||
	{
 | 
			
		||||
		return self::$instance;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										275
									
								
								system/core/Exceptions.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										275
									
								
								system/core/Exceptions.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,275 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Exceptions Class
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Libraries
 | 
			
		||||
 * @category	Exceptions
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/libraries/exceptions.html
 | 
			
		||||
 */
 | 
			
		||||
class CI_Exceptions {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Nesting level of the output buffering mechanism
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	int
 | 
			
		||||
	 */
 | 
			
		||||
	public $ob_level;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List of available error levels
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	public $levels = array(
 | 
			
		||||
		E_ERROR			=>	'Error',
 | 
			
		||||
		E_WARNING		=>	'Warning',
 | 
			
		||||
		E_PARSE			=>	'Parsing Error',
 | 
			
		||||
		E_NOTICE		=>	'Notice',
 | 
			
		||||
		E_CORE_ERROR		=>	'Core Error',
 | 
			
		||||
		E_CORE_WARNING		=>	'Core Warning',
 | 
			
		||||
		E_COMPILE_ERROR		=>	'Compile Error',
 | 
			
		||||
		E_COMPILE_WARNING	=>	'Compile Warning',
 | 
			
		||||
		E_USER_ERROR		=>	'User Error',
 | 
			
		||||
		E_USER_WARNING		=>	'User Warning',
 | 
			
		||||
		E_USER_NOTICE		=>	'User Notice',
 | 
			
		||||
		E_STRICT		=>	'Runtime Notice'
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Class constructor
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct()
 | 
			
		||||
	{
 | 
			
		||||
		$this->ob_level = ob_get_level();
 | 
			
		||||
		// Note: Do not log messages from this constructor.
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Exception Logger
 | 
			
		||||
	 *
 | 
			
		||||
	 * Logs PHP generated error messages
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	int	$severity	Log level
 | 
			
		||||
	 * @param	string	$message	Error message
 | 
			
		||||
	 * @param	string	$filepath	File path
 | 
			
		||||
	 * @param	int	$line		Line number
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function log_exception($severity, $message, $filepath, $line)
 | 
			
		||||
	{
 | 
			
		||||
		$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
 | 
			
		||||
		log_message('error', 'Severity: '.$severity.' --> '.$message.' '.$filepath.' '.$line);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 404 Error Handler
 | 
			
		||||
	 *
 | 
			
		||||
	 * @uses	CI_Exceptions::show_error()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$page		Page URI
 | 
			
		||||
	 * @param 	bool	$log_error	Whether to log the error
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function show_404($page = '', $log_error = TRUE)
 | 
			
		||||
	{
 | 
			
		||||
		if (is_cli())
 | 
			
		||||
		{
 | 
			
		||||
			$heading = 'Not Found';
 | 
			
		||||
			$message = 'The controller/method pair you requested was not found.';
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			$heading = '404 Page Not Found';
 | 
			
		||||
			$message = 'The page you requested was not found.';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// By default we log this, but allow a dev to skip it
 | 
			
		||||
		if ($log_error)
 | 
			
		||||
		{
 | 
			
		||||
			log_message('error', $heading.': '.$page);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		echo $this->show_error($heading, $message, 'error_404', 404);
 | 
			
		||||
		exit(4); // EXIT_UNKNOWN_FILE
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * General Error Page
 | 
			
		||||
	 *
 | 
			
		||||
	 * Takes an error message as input (either as a string or an array)
 | 
			
		||||
	 * and displays it using the specified template.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string		$heading	Page heading
 | 
			
		||||
	 * @param	string|string[]	$message	Error message
 | 
			
		||||
	 * @param	string		$template	Template name
 | 
			
		||||
	 * @param 	int		$status_code	(default: 500)
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	string	Error page output
 | 
			
		||||
	 */
 | 
			
		||||
	public function show_error($heading, $message, $template = 'error_general', $status_code = 500)
 | 
			
		||||
	{
 | 
			
		||||
		$templates_path = config_item('error_views_path');
 | 
			
		||||
		if (empty($templates_path))
 | 
			
		||||
		{
 | 
			
		||||
			$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (is_cli())
 | 
			
		||||
		{
 | 
			
		||||
			$message = "\t".(is_array($message) ? implode("\n\t", $message) : $message);
 | 
			
		||||
			$template = 'cli'.DIRECTORY_SEPARATOR.$template;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			set_status_header($status_code);
 | 
			
		||||
			$message = '<p>'.(is_array($message) ? implode('</p><p>', $message) : $message).'</p>';
 | 
			
		||||
			$template = 'html'.DIRECTORY_SEPARATOR.$template;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (ob_get_level() > $this->ob_level + 1)
 | 
			
		||||
		{
 | 
			
		||||
			ob_end_flush();
 | 
			
		||||
		}
 | 
			
		||||
		ob_start();
 | 
			
		||||
		include($templates_path.$template.'.php');
 | 
			
		||||
		$buffer = ob_get_contents();
 | 
			
		||||
		ob_end_clean();
 | 
			
		||||
		return $buffer;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	public function show_exception($exception)
 | 
			
		||||
	{
 | 
			
		||||
		$templates_path = config_item('error_views_path');
 | 
			
		||||
		if (empty($templates_path))
 | 
			
		||||
		{
 | 
			
		||||
			$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$message = $exception->getMessage();
 | 
			
		||||
		if (empty($message))
 | 
			
		||||
		{
 | 
			
		||||
			$message = '(null)';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (is_cli())
 | 
			
		||||
		{
 | 
			
		||||
			$templates_path .= 'cli'.DIRECTORY_SEPARATOR;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			$templates_path .= 'html'.DIRECTORY_SEPARATOR;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (ob_get_level() > $this->ob_level + 1)
 | 
			
		||||
		{
 | 
			
		||||
			ob_end_flush();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		ob_start();
 | 
			
		||||
		include($templates_path.'error_exception.php');
 | 
			
		||||
		$buffer = ob_get_contents();
 | 
			
		||||
		ob_end_clean();
 | 
			
		||||
		echo $buffer;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Native PHP error handler
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	int	$severity	Error level
 | 
			
		||||
	 * @param	string	$message	Error message
 | 
			
		||||
	 * @param	string	$filepath	File path
 | 
			
		||||
	 * @param	int	$line		Line number
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function show_php_error($severity, $message, $filepath, $line)
 | 
			
		||||
	{
 | 
			
		||||
		$templates_path = config_item('error_views_path');
 | 
			
		||||
		if (empty($templates_path))
 | 
			
		||||
		{
 | 
			
		||||
			$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
 | 
			
		||||
 | 
			
		||||
		// For safety reasons we don't show the full file path in non-CLI requests
 | 
			
		||||
		if ( ! is_cli())
 | 
			
		||||
		{
 | 
			
		||||
			$filepath = str_replace('\\', '/', $filepath);
 | 
			
		||||
			if (FALSE !== strpos($filepath, '/'))
 | 
			
		||||
			{
 | 
			
		||||
				$x = explode('/', $filepath);
 | 
			
		||||
				$filepath = $x[count($x)-2].'/'.end($x);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$template = 'html'.DIRECTORY_SEPARATOR.'error_php';
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			$template = 'cli'.DIRECTORY_SEPARATOR.'error_php';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (ob_get_level() > $this->ob_level + 1)
 | 
			
		||||
		{
 | 
			
		||||
			ob_end_flush();
 | 
			
		||||
		}
 | 
			
		||||
		ob_start();
 | 
			
		||||
		include($templates_path.$template.'.php');
 | 
			
		||||
		$buffer = ob_get_contents();
 | 
			
		||||
		ob_end_clean();
 | 
			
		||||
		echo $buffer;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										267
									
								
								system/core/Hooks.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										267
									
								
								system/core/Hooks.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,267 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Hooks Class
 | 
			
		||||
 *
 | 
			
		||||
 * Provides a mechanism to extend the base system without hacking.
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Libraries
 | 
			
		||||
 * @category	Libraries
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/general/hooks.html
 | 
			
		||||
 */
 | 
			
		||||
class CI_Hooks {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Determines whether hooks are enabled
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public $enabled = FALSE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List of all hooks set in config/hooks.php
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	public $hooks =	array();
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Array with class objects to use hooks methods
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var array
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_objects = array();
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * In progress flag
 | 
			
		||||
	 *
 | 
			
		||||
	 * Determines whether hook is in progress, used to prevent infinte loops
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_in_progress = FALSE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Class constructor
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct()
 | 
			
		||||
	{
 | 
			
		||||
		$CFG =& load_class('Config', 'core');
 | 
			
		||||
		log_message('info', 'Hooks Class Initialized');
 | 
			
		||||
 | 
			
		||||
		// If hooks are not enabled in the config file
 | 
			
		||||
		// there is nothing else to do
 | 
			
		||||
		if ($CFG->item('enable_hooks') === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Grab the "hooks" definition file.
 | 
			
		||||
		if (file_exists(APPPATH.'config/hooks.php'))
 | 
			
		||||
		{
 | 
			
		||||
			include(APPPATH.'config/hooks.php');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
 | 
			
		||||
		{
 | 
			
		||||
			include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// If there are no hooks, we're done.
 | 
			
		||||
		if ( ! isset($hook) OR ! is_array($hook))
 | 
			
		||||
		{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->hooks =& $hook;
 | 
			
		||||
		$this->enabled = TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Call Hook
 | 
			
		||||
	 *
 | 
			
		||||
	 * Calls a particular hook. Called by CodeIgniter.php.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @uses	CI_Hooks::_run_hook()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$which	Hook name
 | 
			
		||||
	 * @return	bool	TRUE on success or FALSE on failure
 | 
			
		||||
	 */
 | 
			
		||||
	public function call_hook($which = '')
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! $this->enabled OR ! isset($this->hooks[$which]))
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (is_array($this->hooks[$which]) && ! isset($this->hooks[$which]['function']))
 | 
			
		||||
		{
 | 
			
		||||
			foreach ($this->hooks[$which] as $val)
 | 
			
		||||
			{
 | 
			
		||||
				$this->_run_hook($val);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			$this->_run_hook($this->hooks[$which]);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Run Hook
 | 
			
		||||
	 *
 | 
			
		||||
	 * Runs a particular hook
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	$data	Hook details
 | 
			
		||||
	 * @return	bool	TRUE on success or FALSE on failure
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _run_hook($data)
 | 
			
		||||
	{
 | 
			
		||||
		// Closures/lambda functions and array($object, 'method') callables
 | 
			
		||||
		if (is_callable($data))
 | 
			
		||||
		{
 | 
			
		||||
			is_array($data)
 | 
			
		||||
				? $data[0]->{$data[1]}()
 | 
			
		||||
				: $data();
 | 
			
		||||
 | 
			
		||||
			return TRUE;
 | 
			
		||||
		}
 | 
			
		||||
		elseif ( ! is_array($data))
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// -----------------------------------
 | 
			
		||||
		// Safety - Prevents run-away loops
 | 
			
		||||
		// -----------------------------------
 | 
			
		||||
 | 
			
		||||
		// If the script being called happens to have the same
 | 
			
		||||
		// hook call within it a loop can happen
 | 
			
		||||
		if ($this->_in_progress === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// -----------------------------------
 | 
			
		||||
		// Set file path
 | 
			
		||||
		// -----------------------------------
 | 
			
		||||
 | 
			
		||||
		if ( ! isset($data['filepath'], $data['filename']))
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$filepath = APPPATH.$data['filepath'].'/'.$data['filename'];
 | 
			
		||||
 | 
			
		||||
		if ( ! file_exists($filepath))
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Determine and class and/or function names
 | 
			
		||||
		$class		= empty($data['class']) ? FALSE : $data['class'];
 | 
			
		||||
		$function	= empty($data['function']) ? FALSE : $data['function'];
 | 
			
		||||
		$params		= isset($data['params']) ? $data['params'] : '';
 | 
			
		||||
 | 
			
		||||
		if (empty($function))
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Set the _in_progress flag
 | 
			
		||||
		$this->_in_progress = TRUE;
 | 
			
		||||
 | 
			
		||||
		// Call the requested class and/or function
 | 
			
		||||
		if ($class !== FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			// The object is stored?
 | 
			
		||||
			if (isset($this->_objects[$class]))
 | 
			
		||||
			{
 | 
			
		||||
				if (method_exists($this->_objects[$class], $function))
 | 
			
		||||
				{
 | 
			
		||||
					$this->_objects[$class]->$function($params);
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					return $this->_in_progress = FALSE;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				class_exists($class, FALSE) OR require_once($filepath);
 | 
			
		||||
 | 
			
		||||
				if ( ! class_exists($class, FALSE) OR ! method_exists($class, $function))
 | 
			
		||||
				{
 | 
			
		||||
					return $this->_in_progress = FALSE;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				// Store the object and execute the method
 | 
			
		||||
				$this->_objects[$class] = new $class();
 | 
			
		||||
				$this->_objects[$class]->$function($params);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			function_exists($function) OR require_once($filepath);
 | 
			
		||||
 | 
			
		||||
			if ( ! function_exists($function))
 | 
			
		||||
			{
 | 
			
		||||
				return $this->_in_progress = FALSE;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$function($params);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->_in_progress = FALSE;
 | 
			
		||||
		return TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										937
									
								
								system/core/Input.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										937
									
								
								system/core/Input.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										204
									
								
								system/core/Lang.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										204
									
								
								system/core/Lang.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,204 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Language Class
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Libraries
 | 
			
		||||
 * @category	Language
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/libraries/language.html
 | 
			
		||||
 */
 | 
			
		||||
class CI_Lang {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List of translations
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	public $language =	array();
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List of loaded language files
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	public $is_loaded =	array();
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Class constructor
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct()
 | 
			
		||||
	{
 | 
			
		||||
		log_message('info', 'Language Class Initialized');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Load a language file
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	mixed	$langfile	Language file name
 | 
			
		||||
	 * @param	string	$idiom		Language name (english, etc.)
 | 
			
		||||
	 * @param	bool	$return		Whether to return the loaded array of translations
 | 
			
		||||
	 * @param 	bool	$add_suffix	Whether to add suffix to $langfile
 | 
			
		||||
	 * @param 	string	$alt_path	Alternative path to look for the language file
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void|string[]	Array containing translations, if $return is set to TRUE
 | 
			
		||||
	 */
 | 
			
		||||
	public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
 | 
			
		||||
	{
 | 
			
		||||
		if (is_array($langfile))
 | 
			
		||||
		{
 | 
			
		||||
			foreach ($langfile as $value)
 | 
			
		||||
			{
 | 
			
		||||
				$this->load($value, $idiom, $return, $add_suffix, $alt_path);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$langfile = str_replace('.php', '', $langfile);
 | 
			
		||||
 | 
			
		||||
		if ($add_suffix === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			$langfile = preg_replace('/_lang$/', '', $langfile).'_lang';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$langfile .= '.php';
 | 
			
		||||
 | 
			
		||||
		if (empty($idiom) OR ! preg_match('/^[a-z_-]+$/i', $idiom))
 | 
			
		||||
		{
 | 
			
		||||
			$config =& get_config();
 | 
			
		||||
			$idiom = empty($config['language']) ? 'english' : $config['language'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($return === FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom)
 | 
			
		||||
		{
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Load the base file, so any others found can override it
 | 
			
		||||
		$basepath = BASEPATH.'language/'.$idiom.'/'.$langfile;
 | 
			
		||||
		if (($found = file_exists($basepath)) === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			include($basepath);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Do we have an alternative path to look in?
 | 
			
		||||
		if ($alt_path !== '')
 | 
			
		||||
		{
 | 
			
		||||
			$alt_path .= 'language/'.$idiom.'/'.$langfile;
 | 
			
		||||
			if (file_exists($alt_path))
 | 
			
		||||
			{
 | 
			
		||||
				include($alt_path);
 | 
			
		||||
				$found = TRUE;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			foreach (get_instance()->load->get_package_paths(TRUE) as $package_path)
 | 
			
		||||
			{
 | 
			
		||||
				$package_path .= 'language/'.$idiom.'/'.$langfile;
 | 
			
		||||
				if ($basepath !== $package_path && file_exists($package_path))
 | 
			
		||||
				{
 | 
			
		||||
					include($package_path);
 | 
			
		||||
					$found = TRUE;
 | 
			
		||||
					break;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($found !== TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! isset($lang) OR ! is_array($lang))
 | 
			
		||||
		{
 | 
			
		||||
			log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
 | 
			
		||||
 | 
			
		||||
			if ($return === TRUE)
 | 
			
		||||
			{
 | 
			
		||||
				return array();
 | 
			
		||||
			}
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($return === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			return $lang;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->is_loaded[$langfile] = $idiom;
 | 
			
		||||
		$this->language = array_merge($this->language, $lang);
 | 
			
		||||
 | 
			
		||||
		log_message('info', 'Language file loaded: language/'.$idiom.'/'.$langfile);
 | 
			
		||||
		return TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Language line
 | 
			
		||||
	 *
 | 
			
		||||
	 * Fetches a single line of text from the language array
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$line		Language line key
 | 
			
		||||
	 * @param	bool	$log_errors	Whether to log an error message if the line is not found
 | 
			
		||||
	 * @return	string	Translation
 | 
			
		||||
	 */
 | 
			
		||||
	public function line($line, $log_errors = TRUE)
 | 
			
		||||
	{
 | 
			
		||||
		$value = isset($this->language[$line]) ? $this->language[$line] : FALSE;
 | 
			
		||||
 | 
			
		||||
		// Because killer robots like unicorns!
 | 
			
		||||
		if ($value === FALSE && $log_errors === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			log_message('error', 'Could not find the language line "'.$line.'"');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $value;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1416
									
								
								system/core/Loader.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1416
									
								
								system/core/Loader.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										297
									
								
								system/core/Log.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										297
									
								
								system/core/Log.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,297 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Logging Class
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Libraries
 | 
			
		||||
 * @category	Logging
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/general/errors.html
 | 
			
		||||
 */
 | 
			
		||||
class CI_Log {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Path to save log files
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_log_path;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * File permissions
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	int
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_file_permissions = 0644;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Level of logging
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var int
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_threshold = 1;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Array of threshold levels to log
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var array
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_threshold_array = array();
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Format of timestamp for log files
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_date_fmt = 'Y-m-d H:i:s';
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Filename extension
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_file_ext;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Whether or not the logger can write to the log files
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_enabled = TRUE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Predefined logging levels
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var array
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_levels = array('ERROR' => 1, 'DEBUG' => 2, 'INFO' => 3, 'ALL' => 4);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * mbstring.func_overload flag
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected static $func_overload;
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Class constructor
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct()
 | 
			
		||||
	{
 | 
			
		||||
		$config =& get_config();
 | 
			
		||||
 | 
			
		||||
		isset(self::$func_overload) OR self::$func_overload = ( ! is_php('8.0') && extension_loaded('mbstring') && @ini_get('mbstring.func_overload'));
 | 
			
		||||
 | 
			
		||||
		$this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/';
 | 
			
		||||
		$this->_file_ext = (isset($config['log_file_extension']) && $config['log_file_extension'] !== '')
 | 
			
		||||
			? ltrim($config['log_file_extension'], '.') : 'php';
 | 
			
		||||
 | 
			
		||||
		file_exists($this->_log_path) OR mkdir($this->_log_path, 0755, TRUE);
 | 
			
		||||
 | 
			
		||||
		if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path))
 | 
			
		||||
		{
 | 
			
		||||
			$this->_enabled = FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (is_numeric($config['log_threshold']))
 | 
			
		||||
		{
 | 
			
		||||
			$this->_threshold = (int) $config['log_threshold'];
 | 
			
		||||
		}
 | 
			
		||||
		elseif (is_array($config['log_threshold']))
 | 
			
		||||
		{
 | 
			
		||||
			$this->_threshold = 0;
 | 
			
		||||
			$this->_threshold_array = array_flip($config['log_threshold']);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! empty($config['log_date_format']))
 | 
			
		||||
		{
 | 
			
		||||
			$this->_date_fmt = $config['log_date_format'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! empty($config['log_file_permissions']) && is_int($config['log_file_permissions']))
 | 
			
		||||
		{
 | 
			
		||||
			$this->_file_permissions = $config['log_file_permissions'];
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Write Log File
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generally this function will be called using the global log_message() function
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$level 	The error level: 'error', 'debug' or 'info'
 | 
			
		||||
	 * @param	string	$msg 	The error message
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public function write_log($level, $msg)
 | 
			
		||||
	{
 | 
			
		||||
		if ($this->_enabled === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$level = strtoupper($level);
 | 
			
		||||
 | 
			
		||||
		if (( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
 | 
			
		||||
			&& ! isset($this->_threshold_array[$this->_levels[$level]]))
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$filepath = $this->_log_path.'log-'.date('Y-m-d').'.'.$this->_file_ext;
 | 
			
		||||
		$message = '';
 | 
			
		||||
 | 
			
		||||
		if ( ! file_exists($filepath))
 | 
			
		||||
		{
 | 
			
		||||
			$newfile = TRUE;
 | 
			
		||||
			// Only add protection to php files
 | 
			
		||||
			if ($this->_file_ext === 'php')
 | 
			
		||||
			{
 | 
			
		||||
				$message .= "<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>\n\n";
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! $fp = @fopen($filepath, 'ab'))
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		flock($fp, LOCK_EX);
 | 
			
		||||
 | 
			
		||||
		// Instantiating DateTime with microseconds appended to initial date is needed for proper support of this format
 | 
			
		||||
		if (strpos($this->_date_fmt, 'u') !== FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			$microtime_full = microtime(TRUE);
 | 
			
		||||
			$microtime_short = sprintf("%06d", ($microtime_full - floor($microtime_full)) * 1000000);
 | 
			
		||||
			$date = new DateTime(date('Y-m-d H:i:s.'.$microtime_short, $microtime_full));
 | 
			
		||||
			$date = $date->format($this->_date_fmt);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			$date = date($this->_date_fmt);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$message .= $this->_format_line($level, $date, $msg);
 | 
			
		||||
 | 
			
		||||
		for ($written = 0, $length = self::strlen($message); $written < $length; $written += $result)
 | 
			
		||||
		{
 | 
			
		||||
			if (($result = fwrite($fp, self::substr($message, $written))) === FALSE)
 | 
			
		||||
			{
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		flock($fp, LOCK_UN);
 | 
			
		||||
		fclose($fp);
 | 
			
		||||
 | 
			
		||||
		if (isset($newfile) && $newfile === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			chmod($filepath, $this->_file_permissions);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return is_int($result);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Format the log line.
 | 
			
		||||
	 *
 | 
			
		||||
	 * This is for extensibility of log formatting
 | 
			
		||||
	 * If you want to change the log format, extend the CI_Log class and override this method
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$level 	The error level
 | 
			
		||||
	 * @param	string	$date 	Formatted date string
 | 
			
		||||
	 * @param	string	$message 	The log message
 | 
			
		||||
	 * @return	string	Formatted log line with a new line character at the end
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _format_line($level, $date, $message)
 | 
			
		||||
	{
 | 
			
		||||
		return $level.' - '.$date.' --> '.$message.PHP_EOL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Byte-safe strlen()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$str
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	protected static function strlen($str)
 | 
			
		||||
	{
 | 
			
		||||
		return (self::$func_overload)
 | 
			
		||||
			? mb_strlen($str, '8bit')
 | 
			
		||||
			: strlen($str);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Byte-safe substr()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$str
 | 
			
		||||
	 * @param	int	$start
 | 
			
		||||
	 * @param	int	$length
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected static function substr($str, $start, $length = NULL)
 | 
			
		||||
	{
 | 
			
		||||
		if (self::$func_overload)
 | 
			
		||||
		{
 | 
			
		||||
			// mb_substr($str, $start, null, '8bit') returns an empty
 | 
			
		||||
			// string on PHP 5.3
 | 
			
		||||
			isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
 | 
			
		||||
			return mb_substr($str, $start, $length, '8bit');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return isset($length)
 | 
			
		||||
			? substr($str, $start, $length)
 | 
			
		||||
			: substr($str, $start);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										77
									
								
								system/core/Model.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								system/core/Model.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,77 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Model Class
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Libraries
 | 
			
		||||
 * @category	Libraries
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/libraries/config.html
 | 
			
		||||
 */
 | 
			
		||||
class CI_Model {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Class constructor
 | 
			
		||||
	 *
 | 
			
		||||
	 * @link	https://github.com/bcit-ci/CodeIgniter/issues/5332
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct() {}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * __get magic
 | 
			
		||||
	 *
 | 
			
		||||
	 * Allows models to access CI's loaded classes using the same
 | 
			
		||||
	 * syntax as controllers.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$key
 | 
			
		||||
	 */
 | 
			
		||||
	public function __get($key)
 | 
			
		||||
	{
 | 
			
		||||
		// Debugging note:
 | 
			
		||||
		//	If you're here because you're getting an error message
 | 
			
		||||
		//	saying 'Undefined Property: system/core/Model.php', it's
 | 
			
		||||
		//	most likely a typo in your model code.
 | 
			
		||||
		return get_instance()->$key;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										847
									
								
								system/core/Output.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										847
									
								
								system/core/Output.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										516
									
								
								system/core/Router.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										516
									
								
								system/core/Router.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1111
									
								
								system/core/Security.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1111
									
								
								system/core/Security.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										644
									
								
								system/core/URI.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										644
									
								
								system/core/URI.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										165
									
								
								system/core/Utf8.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										165
									
								
								system/core/Utf8.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,165 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 2.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Utf8 Class
 | 
			
		||||
 *
 | 
			
		||||
 * Provides support for UTF-8 environments
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Libraries
 | 
			
		||||
 * @category	UTF-8
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/libraries/utf8.html
 | 
			
		||||
 */
 | 
			
		||||
class CI_Utf8 {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Class constructor
 | 
			
		||||
	 *
 | 
			
		||||
	 * Determines if UTF-8 support is to be enabled.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct()
 | 
			
		||||
	{
 | 
			
		||||
		if (
 | 
			
		||||
			defined('PREG_BAD_UTF8_ERROR')				// PCRE must support UTF-8
 | 
			
		||||
			&& (ICONV_ENABLED === TRUE OR MB_ENABLED === TRUE)	// iconv or mbstring must be installed
 | 
			
		||||
			&& strtoupper(config_item('charset')) === 'UTF-8'	// Application charset must be UTF-8
 | 
			
		||||
			)
 | 
			
		||||
		{
 | 
			
		||||
			define('UTF8_ENABLED', TRUE);
 | 
			
		||||
			log_message('debug', 'UTF-8 Support Enabled');
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			define('UTF8_ENABLED', FALSE);
 | 
			
		||||
			log_message('debug', 'UTF-8 Support Disabled');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log_message('info', 'Utf8 Class Initialized');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Clean UTF-8 strings
 | 
			
		||||
	 *
 | 
			
		||||
	 * Ensures strings contain only valid UTF-8 characters.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$str	String to clean
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	public function clean_string($str)
 | 
			
		||||
	{
 | 
			
		||||
		if ($this->is_ascii($str) === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			if (MB_ENABLED)
 | 
			
		||||
			{
 | 
			
		||||
				$str = mb_convert_encoding($str, 'UTF-8', 'UTF-8');
 | 
			
		||||
			}
 | 
			
		||||
			elseif (ICONV_ENABLED)
 | 
			
		||||
			{
 | 
			
		||||
				$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $str;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Remove ASCII control characters
 | 
			
		||||
	 *
 | 
			
		||||
	 * Removes all ASCII control characters except horizontal tabs,
 | 
			
		||||
	 * line feeds, and carriage returns, as all others can cause
 | 
			
		||||
	 * problems in XML.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$str	String to clean
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	public function safe_ascii_for_xml($str)
 | 
			
		||||
	{
 | 
			
		||||
		return remove_invisible_characters($str, FALSE);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Convert to UTF-8
 | 
			
		||||
	 *
 | 
			
		||||
	 * Attempts to convert a string to UTF-8.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$str		Input string
 | 
			
		||||
	 * @param	string	$encoding	Input encoding
 | 
			
		||||
	 * @return	string	$str encoded in UTF-8 or FALSE on failure
 | 
			
		||||
	 */
 | 
			
		||||
	public function convert_to_utf8($str, $encoding)
 | 
			
		||||
	{
 | 
			
		||||
		if (MB_ENABLED)
 | 
			
		||||
		{
 | 
			
		||||
			return mb_convert_encoding($str, 'UTF-8', $encoding);
 | 
			
		||||
		}
 | 
			
		||||
		elseif (ICONV_ENABLED)
 | 
			
		||||
		{
 | 
			
		||||
			return @iconv($encoding, 'UTF-8', $str);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return FALSE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Is ASCII?
 | 
			
		||||
	 *
 | 
			
		||||
	 * Tests if a string is standard 7-bit ASCII or not.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$str	String to check
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public function is_ascii($str)
 | 
			
		||||
	{
 | 
			
		||||
		return (preg_match('/[^\x00-\x7F]/S', $str) === 0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										255
									
								
								system/core/compat/hash.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										255
									
								
								system/core/compat/hash.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,255 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 3.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * PHP ext/hash compatibility package
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	CodeIgniter
 | 
			
		||||
 * @category	Compatibility
 | 
			
		||||
 * @author		Andrey Andreev
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/
 | 
			
		||||
 * @link		https://secure.php.net/hash
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if (is_php('5.6'))
 | 
			
		||||
{
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if ( ! function_exists('hash_equals'))
 | 
			
		||||
{
 | 
			
		||||
	/**
 | 
			
		||||
	 * hash_equals()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @link	http://php.net/hash_equals
 | 
			
		||||
	 * @param	string	$known_string
 | 
			
		||||
	 * @param	string	$user_string
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	function hash_equals($known_string, $user_string)
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! is_string($known_string))
 | 
			
		||||
		{
 | 
			
		||||
			trigger_error('hash_equals(): Expected known_string to be a string, '.strtolower(gettype($known_string)).' given', E_USER_WARNING);
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
		elseif ( ! is_string($user_string))
 | 
			
		||||
		{
 | 
			
		||||
			trigger_error('hash_equals(): Expected user_string to be a string, '.strtolower(gettype($user_string)).' given', E_USER_WARNING);
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
		elseif (($length = strlen($known_string)) !== strlen($user_string))
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$diff = 0;
 | 
			
		||||
		for ($i = 0; $i < $length; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			$diff |= ord($known_string[$i]) ^ ord($user_string[$i]);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return ($diff === 0);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if (is_php('5.5'))
 | 
			
		||||
{
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if ( ! function_exists('hash_pbkdf2'))
 | 
			
		||||
{
 | 
			
		||||
	/**
 | 
			
		||||
	 * hash_pbkdf2()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @link	http://php.net/hash_pbkdf2
 | 
			
		||||
	 * @param	string	$algo
 | 
			
		||||
	 * @param	string	$password
 | 
			
		||||
	 * @param	string	$salt
 | 
			
		||||
	 * @param	int	$iterations
 | 
			
		||||
	 * @param	int	$length
 | 
			
		||||
	 * @param	bool	$raw_output
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	function hash_pbkdf2($algo, $password, $salt, $iterations, $length = 0, $raw_output = FALSE)
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! in_array(strtolower($algo), hash_algos(), TRUE))
 | 
			
		||||
		{
 | 
			
		||||
			trigger_error('hash_pbkdf2(): Unknown hashing algorithm: '.$algo, E_USER_WARNING);
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (($type = gettype($iterations)) !== 'integer')
 | 
			
		||||
		{
 | 
			
		||||
			if ($type === 'object' && method_exists($iterations, '__toString'))
 | 
			
		||||
			{
 | 
			
		||||
				$iterations = (string) $iterations;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (is_string($iterations) && is_numeric($iterations))
 | 
			
		||||
			{
 | 
			
		||||
				$iterations = (int) $iterations;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				trigger_error('hash_pbkdf2() expects parameter 4 to be long, '.$type.' given', E_USER_WARNING);
 | 
			
		||||
				return NULL;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($iterations < 1)
 | 
			
		||||
		{
 | 
			
		||||
			trigger_error('hash_pbkdf2(): Iterations must be a positive integer: '.$iterations, E_USER_WARNING);
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (($type = gettype($length)) !== 'integer')
 | 
			
		||||
		{
 | 
			
		||||
			if ($type === 'object' && method_exists($length, '__toString'))
 | 
			
		||||
			{
 | 
			
		||||
				$length = (string) $length;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (is_string($length) && is_numeric($length))
 | 
			
		||||
			{
 | 
			
		||||
				$length = (int) $length;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				trigger_error('hash_pbkdf2() expects parameter 5 to be long, '.$type.' given', E_USER_WARNING);
 | 
			
		||||
				return NULL;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($length < 0)
 | 
			
		||||
		{
 | 
			
		||||
			trigger_error('hash_pbkdf2(): Length must be greater than or equal to 0: '.$length, E_USER_WARNING);
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$hash_length = defined('MB_OVERLOAD_STRING')
 | 
			
		||||
			? mb_strlen(hash($algo, NULL, TRUE), '8bit')
 | 
			
		||||
			: strlen(hash($algo, NULL, TRUE));
 | 
			
		||||
		empty($length) && $length = $hash_length;
 | 
			
		||||
 | 
			
		||||
		// Pre-hash password inputs longer than the algorithm's block size
 | 
			
		||||
		// (i.e. prepare HMAC key) to mitigate potential DoS attacks.
 | 
			
		||||
		static $block_sizes;
 | 
			
		||||
		empty($block_sizes) && $block_sizes = array(
 | 
			
		||||
			'gost' => 32,
 | 
			
		||||
			'haval128,3' => 128,
 | 
			
		||||
			'haval160,3' => 128,
 | 
			
		||||
			'haval192,3' => 128,
 | 
			
		||||
			'haval224,3' => 128,
 | 
			
		||||
			'haval256,3' => 128,
 | 
			
		||||
			'haval128,4' => 128,
 | 
			
		||||
			'haval160,4' => 128,
 | 
			
		||||
			'haval192,4' => 128,
 | 
			
		||||
			'haval224,4' => 128,
 | 
			
		||||
			'haval256,4' => 128,
 | 
			
		||||
			'haval128,5' => 128,
 | 
			
		||||
			'haval160,5' => 128,
 | 
			
		||||
			'haval192,5' => 128,
 | 
			
		||||
			'haval224,5' => 128,
 | 
			
		||||
			'haval256,5' => 128,
 | 
			
		||||
			'md2' => 16,
 | 
			
		||||
			'md4' => 64,
 | 
			
		||||
			'md5' => 64,
 | 
			
		||||
			'ripemd128' => 64,
 | 
			
		||||
			'ripemd160' => 64,
 | 
			
		||||
			'ripemd256' => 64,
 | 
			
		||||
			'ripemd320' => 64,
 | 
			
		||||
			'salsa10' => 64,
 | 
			
		||||
			'salsa20' => 64,
 | 
			
		||||
			'sha1' => 64,
 | 
			
		||||
			'sha224' => 64,
 | 
			
		||||
			'sha256' => 64,
 | 
			
		||||
			'sha384' => 128,
 | 
			
		||||
			'sha512' => 128,
 | 
			
		||||
			'snefru' => 32,
 | 
			
		||||
			'snefru256' => 32,
 | 
			
		||||
			'tiger128,3' => 64,
 | 
			
		||||
			'tiger160,3' => 64,
 | 
			
		||||
			'tiger192,3' => 64,
 | 
			
		||||
			'tiger128,4' => 64,
 | 
			
		||||
			'tiger160,4' => 64,
 | 
			
		||||
			'tiger192,4' => 64,
 | 
			
		||||
			'whirlpool' => 64
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		if (isset($block_sizes[$algo], $password[$block_sizes[$algo]]))
 | 
			
		||||
		{
 | 
			
		||||
			$password = hash($algo, $password, TRUE);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$hash = '';
 | 
			
		||||
		// Note: Blocks are NOT 0-indexed
 | 
			
		||||
		for ($bc = (int) ceil($length / $hash_length), $bi = 1; $bi <= $bc; $bi++)
 | 
			
		||||
		{
 | 
			
		||||
			$key = $derived_key = hash_hmac($algo, $salt.pack('N', $bi), $password, TRUE);
 | 
			
		||||
			for ($i = 1; $i < $iterations; $i++)
 | 
			
		||||
			{
 | 
			
		||||
				$derived_key ^= $key = hash_hmac($algo, $key, $password, TRUE);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$hash .= $derived_key;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// This is not RFC-compatible, but we're aiming for natural PHP compatibility
 | 
			
		||||
		if ( ! $raw_output)
 | 
			
		||||
		{
 | 
			
		||||
			$hash = bin2hex($hash);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return defined('MB_OVERLOAD_STRING')
 | 
			
		||||
			? mb_substr($hash, 0, $length, '8bit')
 | 
			
		||||
			: substr($hash, 0, $length);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								system/core/compat/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								system/core/compat/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
	<title>403 Forbidden</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<p>Directory access is forbidden.</p>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										150
									
								
								system/core/compat/mbstring.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										150
									
								
								system/core/compat/mbstring.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,150 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 3.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * PHP ext/mbstring compatibility package
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	CodeIgniter
 | 
			
		||||
 * @category	Compatibility
 | 
			
		||||
 * @author		Andrey Andreev
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/
 | 
			
		||||
 * @link		https://secure.php.net/mbstring
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if (MB_ENABLED === TRUE)
 | 
			
		||||
{
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if ( ! function_exists('mb_strlen'))
 | 
			
		||||
{
 | 
			
		||||
	/**
 | 
			
		||||
	 * mb_strlen()
 | 
			
		||||
	 *
 | 
			
		||||
	 * WARNING: This function WILL fall-back to strlen()
 | 
			
		||||
	 * if iconv is not available!
 | 
			
		||||
	 *
 | 
			
		||||
	 * @link	http://php.net/mb_strlen
 | 
			
		||||
	 * @param	string	$str
 | 
			
		||||
	 * @param	string	$encoding
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	function mb_strlen($str, $encoding = NULL)
 | 
			
		||||
	{
 | 
			
		||||
		if (ICONV_ENABLED === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			return iconv_strlen($str, isset($encoding) ? $encoding : config_item('charset'));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log_message('debug', 'Compatibility (mbstring): iconv_strlen() is not available, falling back to strlen().');
 | 
			
		||||
		return strlen($str);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if ( ! function_exists('mb_strpos'))
 | 
			
		||||
{
 | 
			
		||||
	/**
 | 
			
		||||
	 * mb_strpos()
 | 
			
		||||
	 *
 | 
			
		||||
	 * WARNING: This function WILL fall-back to strpos()
 | 
			
		||||
	 * if iconv is not available!
 | 
			
		||||
	 *
 | 
			
		||||
	 * @link	http://php.net/mb_strpos
 | 
			
		||||
	 * @param	string	$haystack
 | 
			
		||||
	 * @param	string	$needle
 | 
			
		||||
	 * @param	int	$offset
 | 
			
		||||
	 * @param	string	$encoding
 | 
			
		||||
	 * @return	mixed
 | 
			
		||||
	 */
 | 
			
		||||
	function mb_strpos($haystack, $needle, $offset = 0, $encoding = NULL)
 | 
			
		||||
	{
 | 
			
		||||
		if (ICONV_ENABLED === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			return iconv_strpos($haystack, $needle, $offset, isset($encoding) ? $encoding : config_item('charset'));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log_message('debug', 'Compatibility (mbstring): iconv_strpos() is not available, falling back to strpos().');
 | 
			
		||||
		return strpos($haystack, $needle, $offset);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if ( ! function_exists('mb_substr'))
 | 
			
		||||
{
 | 
			
		||||
	/**
 | 
			
		||||
	 * mb_substr()
 | 
			
		||||
	 *
 | 
			
		||||
	 * WARNING: This function WILL fall-back to substr()
 | 
			
		||||
	 * if iconv is not available.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @link	http://php.net/mb_substr
 | 
			
		||||
	 * @param	string	$str
 | 
			
		||||
	 * @param	int	$start
 | 
			
		||||
	 * @param	int 	$length
 | 
			
		||||
	 * @param	string	$encoding
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	function mb_substr($str, $start, $length = NULL, $encoding = NULL)
 | 
			
		||||
	{
 | 
			
		||||
		if (ICONV_ENABLED === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			isset($encoding) OR $encoding = config_item('charset');
 | 
			
		||||
			return iconv_substr(
 | 
			
		||||
				$str,
 | 
			
		||||
				$start,
 | 
			
		||||
				isset($length) ? $length : iconv_strlen($str, $encoding), // NULL doesn't work
 | 
			
		||||
				$encoding
 | 
			
		||||
			);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		log_message('debug', 'Compatibility (mbstring): iconv_substr() is not available, falling back to substr().');
 | 
			
		||||
		return isset($length)
 | 
			
		||||
			? substr($str, $start, $length)
 | 
			
		||||
			: substr($str, $start);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										252
									
								
								system/core/compat/password.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										252
									
								
								system/core/compat/password.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,252 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 3.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * PHP ext/standard/password compatibility package
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	CodeIgniter
 | 
			
		||||
 * @category	Compatibility
 | 
			
		||||
 * @author		Andrey Andreev
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/
 | 
			
		||||
 * @link		https://secure.php.net/password
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if (is_php('5.5') OR ! defined('CRYPT_BLOWFISH') OR CRYPT_BLOWFISH !== 1 OR defined('HHVM_VERSION'))
 | 
			
		||||
{
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
defined('PASSWORD_BCRYPT') OR define('PASSWORD_BCRYPT', 1);
 | 
			
		||||
defined('PASSWORD_DEFAULT') OR define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if ( ! function_exists('password_get_info'))
 | 
			
		||||
{
 | 
			
		||||
	/**
 | 
			
		||||
	 * password_get_info()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @link	http://php.net/password_get_info
 | 
			
		||||
	 * @param	string	$hash
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	function password_get_info($hash)
 | 
			
		||||
	{
 | 
			
		||||
		return (strlen($hash) < 60 OR sscanf($hash, '$2y$%d', $hash) !== 1)
 | 
			
		||||
			? array('algo' => 0, 'algoName' => 'unknown', 'options' => array())
 | 
			
		||||
			: array('algo' => 1, 'algoName' => 'bcrypt', 'options' => array('cost' => $hash));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if ( ! function_exists('password_hash'))
 | 
			
		||||
{
 | 
			
		||||
	/**
 | 
			
		||||
	 * password_hash()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @link	http://php.net/password_hash
 | 
			
		||||
	 * @param	string	$password
 | 
			
		||||
	 * @param	int	$algo
 | 
			
		||||
	 * @param	array	$options
 | 
			
		||||
	 * @return	mixed
 | 
			
		||||
	 */
 | 
			
		||||
	function password_hash($password, $algo, array $options = array())
 | 
			
		||||
	{
 | 
			
		||||
		static $func_overload;
 | 
			
		||||
		isset($func_overload) OR $func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
 | 
			
		||||
 | 
			
		||||
		if ($algo !== 1)
 | 
			
		||||
		{
 | 
			
		||||
			trigger_error('password_hash(): Unknown hashing algorithm: '.(int) $algo, E_USER_WARNING);
 | 
			
		||||
			return NULL;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (isset($options['cost']) && ($options['cost'] < 4 OR $options['cost'] > 31))
 | 
			
		||||
		{
 | 
			
		||||
			trigger_error('password_hash(): Invalid bcrypt cost parameter specified: '.(int) $options['cost'], E_USER_WARNING);
 | 
			
		||||
			return NULL;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (isset($options['salt']) && ($saltlen = ($func_overload ? mb_strlen($options['salt'], '8bit') : strlen($options['salt']))) < 22)
 | 
			
		||||
		{
 | 
			
		||||
			trigger_error('password_hash(): Provided salt is too short: '.$saltlen.' expecting 22', E_USER_WARNING);
 | 
			
		||||
			return NULL;
 | 
			
		||||
		}
 | 
			
		||||
		elseif ( ! isset($options['salt']))
 | 
			
		||||
		{
 | 
			
		||||
			if (function_exists('random_bytes'))
 | 
			
		||||
			{
 | 
			
		||||
				try
 | 
			
		||||
				{
 | 
			
		||||
					$options['salt'] = random_bytes(16);
 | 
			
		||||
				}
 | 
			
		||||
				catch (Exception $e)
 | 
			
		||||
				{
 | 
			
		||||
					log_message('error', 'compat/password: Error while trying to use random_bytes(): '.$e->getMessage());
 | 
			
		||||
					return FALSE;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			elseif (defined('MCRYPT_DEV_URANDOM'))
 | 
			
		||||
			{
 | 
			
		||||
				$options['salt'] = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM);
 | 
			
		||||
			}
 | 
			
		||||
			elseif (DIRECTORY_SEPARATOR === '/' && (is_readable($dev = '/dev/arandom') OR is_readable($dev = '/dev/urandom')))
 | 
			
		||||
			{
 | 
			
		||||
				if (($fp = fopen($dev, 'rb')) === FALSE)
 | 
			
		||||
				{
 | 
			
		||||
					log_message('error', 'compat/password: Unable to open '.$dev.' for reading.');
 | 
			
		||||
					return FALSE;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				// Try not to waste entropy ...
 | 
			
		||||
				is_php('5.4') && stream_set_chunk_size($fp, 16);
 | 
			
		||||
 | 
			
		||||
				$options['salt'] = '';
 | 
			
		||||
				for ($read = 0; $read < 16; $read = ($func_overload) ? mb_strlen($options['salt'], '8bit') : strlen($options['salt']))
 | 
			
		||||
				{
 | 
			
		||||
					if (($read = fread($fp, 16 - $read)) === FALSE)
 | 
			
		||||
					{
 | 
			
		||||
						log_message('error', 'compat/password: Error while reading from '.$dev.'.');
 | 
			
		||||
						return FALSE;
 | 
			
		||||
					}
 | 
			
		||||
					$options['salt'] .= $read;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				fclose($fp);
 | 
			
		||||
			}
 | 
			
		||||
			elseif (function_exists('openssl_random_pseudo_bytes'))
 | 
			
		||||
			{
 | 
			
		||||
				$is_secure = NULL;
 | 
			
		||||
				$options['salt'] = openssl_random_pseudo_bytes(16, $is_secure);
 | 
			
		||||
				if ($is_secure !== TRUE)
 | 
			
		||||
				{
 | 
			
		||||
					log_message('error', 'compat/password: openssl_random_pseudo_bytes() set the $cryto_strong flag to FALSE');
 | 
			
		||||
					return FALSE;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				log_message('error', 'compat/password: No CSPRNG available.');
 | 
			
		||||
				return FALSE;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$options['salt'] = str_replace('+', '.', rtrim(base64_encode($options['salt']), '='));
 | 
			
		||||
		}
 | 
			
		||||
		elseif ( ! preg_match('#^[a-zA-Z0-9./]+$#D', $options['salt']))
 | 
			
		||||
		{
 | 
			
		||||
			$options['salt'] = str_replace('+', '.', rtrim(base64_encode($options['salt']), '='));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		isset($options['cost']) OR $options['cost'] = 10;
 | 
			
		||||
 | 
			
		||||
		return (strlen($password = crypt($password, sprintf('$2y$%02d$%s', $options['cost'], $options['salt']))) === 60)
 | 
			
		||||
			? $password
 | 
			
		||||
			: FALSE;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if ( ! function_exists('password_needs_rehash'))
 | 
			
		||||
{
 | 
			
		||||
	/**
 | 
			
		||||
	 * password_needs_rehash()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @link	http://php.net/password_needs_rehash
 | 
			
		||||
	 * @param	string	$hash
 | 
			
		||||
	 * @param	int	$algo
 | 
			
		||||
	 * @param	array	$options
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	function password_needs_rehash($hash, $algo, array $options = array())
 | 
			
		||||
	{
 | 
			
		||||
		$info = password_get_info($hash);
 | 
			
		||||
 | 
			
		||||
		if ($algo !== $info['algo'])
 | 
			
		||||
		{
 | 
			
		||||
			return TRUE;
 | 
			
		||||
		}
 | 
			
		||||
		elseif ($algo === 1)
 | 
			
		||||
		{
 | 
			
		||||
			$options['cost'] = isset($options['cost']) ? (int) $options['cost'] : 10;
 | 
			
		||||
			return ($info['options']['cost'] !== $options['cost']);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Odd at first glance, but according to a comment in PHP's own unit tests,
 | 
			
		||||
		// because it is an unknown algorithm - it's valid and therefore doesn't
 | 
			
		||||
		// need rehashing.
 | 
			
		||||
		return FALSE;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if ( ! function_exists('password_verify'))
 | 
			
		||||
{
 | 
			
		||||
	/**
 | 
			
		||||
	 * password_verify()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @link	http://php.net/password_verify
 | 
			
		||||
	 * @param	string	$password
 | 
			
		||||
	 * @param	string	$hash
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	function password_verify($password, $hash)
 | 
			
		||||
	{
 | 
			
		||||
		if (strlen($hash) !== 60 OR strlen($password = crypt($password, $hash)) !== 60)
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$compare = 0;
 | 
			
		||||
		for ($i = 0; $i < 60; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			$compare |= (ord($password[$i]) ^ ord($hash[$i]));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return ($compare === 0);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										183
									
								
								system/core/compat/standard.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										183
									
								
								system/core/compat/standard.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,183 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 3.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * PHP ext/standard compatibility package
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	CodeIgniter
 | 
			
		||||
 * @category	Compatibility
 | 
			
		||||
 * @author		Andrey Andreev
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if (is_php('5.5'))
 | 
			
		||||
{
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if ( ! function_exists('array_column'))
 | 
			
		||||
{
 | 
			
		||||
	/**
 | 
			
		||||
	 * array_column()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @link	http://php.net/array_column
 | 
			
		||||
	 * @param	array	$array
 | 
			
		||||
	 * @param	mixed	$column_key
 | 
			
		||||
	 * @param	mixed	$index_key
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	function array_column(array $array, $column_key, $index_key = NULL)
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! in_array($type = gettype($column_key), array('integer', 'string', 'NULL'), TRUE))
 | 
			
		||||
		{
 | 
			
		||||
			if ($type === 'double')
 | 
			
		||||
			{
 | 
			
		||||
				$column_key = (int) $column_key;
 | 
			
		||||
			}
 | 
			
		||||
			elseif ($type === 'object' && method_exists($column_key, '__toString'))
 | 
			
		||||
			{
 | 
			
		||||
				$column_key = (string) $column_key;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
 | 
			
		||||
				return FALSE;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! in_array($type = gettype($index_key), array('integer', 'string', 'NULL'), TRUE))
 | 
			
		||||
		{
 | 
			
		||||
			if ($type === 'double')
 | 
			
		||||
			{
 | 
			
		||||
				$index_key = (int) $index_key;
 | 
			
		||||
			}
 | 
			
		||||
			elseif ($type === 'object' && method_exists($index_key, '__toString'))
 | 
			
		||||
			{
 | 
			
		||||
				$index_key = (string) $index_key;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
 | 
			
		||||
				return FALSE;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$result = array();
 | 
			
		||||
		foreach ($array as &$a)
 | 
			
		||||
		{
 | 
			
		||||
			if ($column_key === NULL)
 | 
			
		||||
			{
 | 
			
		||||
				$value = $a;
 | 
			
		||||
			}
 | 
			
		||||
			elseif (is_array($a) && array_key_exists($column_key, $a))
 | 
			
		||||
			{
 | 
			
		||||
				$value = $a[$column_key];
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if ($index_key === NULL OR ! array_key_exists($index_key, $a))
 | 
			
		||||
			{
 | 
			
		||||
				$result[] = $value;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				$result[$a[$index_key]] = $value;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $result;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if (is_php('5.4'))
 | 
			
		||||
{
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
if ( ! function_exists('hex2bin'))
 | 
			
		||||
{
 | 
			
		||||
	/**
 | 
			
		||||
	 * hex2bin()
 | 
			
		||||
	 *
 | 
			
		||||
	 * @link	http://php.net/hex2bin
 | 
			
		||||
	 * @param	string	$data
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	function hex2bin($data)
 | 
			
		||||
	{
 | 
			
		||||
		if (in_array($type = gettype($data), array('array', 'double', 'object', 'resource'), TRUE))
 | 
			
		||||
		{
 | 
			
		||||
			if ($type === 'object' && method_exists($data, '__toString'))
 | 
			
		||||
			{
 | 
			
		||||
				$data = (string) $data;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				trigger_error('hex2bin() expects parameter 1 to be string, '.$type.' given', E_USER_WARNING);
 | 
			
		||||
				return NULL;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (strlen($data) % 2 !== 0)
 | 
			
		||||
		{
 | 
			
		||||
			trigger_error('Hexadecimal input string must have an even length', E_USER_WARNING);
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
		elseif ( ! preg_match('/^[0-9a-f]*$/i', $data))
 | 
			
		||||
		{
 | 
			
		||||
			trigger_error('Input string must be hexadecimal string', E_USER_WARNING);
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return pack('H*', $data);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								system/core/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								system/core/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
	<title>403 Forbidden</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<p>Directory access is forbidden.</p>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										219
									
								
								system/database/DB.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										219
									
								
								system/database/DB.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,219 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Initialize the database
 | 
			
		||||
 *
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @link	https://codeigniter.com/userguide3/database/
 | 
			
		||||
 *
 | 
			
		||||
 * @param 	string|string[]	$params
 | 
			
		||||
 * @param 	bool		$query_builder_override
 | 
			
		||||
 *				Determines if query builder should be used or not
 | 
			
		||||
 */
 | 
			
		||||
function &DB($params = '', $query_builder_override = NULL)
 | 
			
		||||
{
 | 
			
		||||
	// Load the DB config file if a DSN string wasn't passed
 | 
			
		||||
	if (is_string($params) && strpos($params, '://') === FALSE)
 | 
			
		||||
	{
 | 
			
		||||
		// Is the config file in the environment folder?
 | 
			
		||||
		if ( ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php')
 | 
			
		||||
			&& ! file_exists($file_path = APPPATH.'config/database.php'))
 | 
			
		||||
		{
 | 
			
		||||
			show_error('The configuration file database.php does not exist.');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		include($file_path);
 | 
			
		||||
 | 
			
		||||
		// Make packages contain database config files,
 | 
			
		||||
		// given that the controller instance already exists
 | 
			
		||||
		if (class_exists('CI_Controller', FALSE))
 | 
			
		||||
		{
 | 
			
		||||
			foreach (get_instance()->load->get_package_paths() as $path)
 | 
			
		||||
			{
 | 
			
		||||
				if ($path !== APPPATH)
 | 
			
		||||
				{
 | 
			
		||||
					if (file_exists($file_path = $path.'config/'.ENVIRONMENT.'/database.php'))
 | 
			
		||||
					{
 | 
			
		||||
						include($file_path);
 | 
			
		||||
					}
 | 
			
		||||
					elseif (file_exists($file_path = $path.'config/database.php'))
 | 
			
		||||
					{
 | 
			
		||||
						include($file_path);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! isset($db) OR count($db) === 0)
 | 
			
		||||
		{
 | 
			
		||||
			show_error('No database connection settings were found in the database config file.');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($params !== '')
 | 
			
		||||
		{
 | 
			
		||||
			$active_group = $params;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! isset($active_group))
 | 
			
		||||
		{
 | 
			
		||||
			show_error('You have not specified a database connection group via $active_group in your config/database.php file.');
 | 
			
		||||
		}
 | 
			
		||||
		elseif ( ! isset($db[$active_group]))
 | 
			
		||||
		{
 | 
			
		||||
			show_error('You have specified an invalid database connection group ('.$active_group.') in your config/database.php file.');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$params = $db[$active_group];
 | 
			
		||||
	}
 | 
			
		||||
	elseif (is_string($params))
 | 
			
		||||
	{
 | 
			
		||||
		/**
 | 
			
		||||
		 * Parse the URL from the DSN string
 | 
			
		||||
		 * Database settings can be passed as discreet
 | 
			
		||||
		 * parameters or as a data source name in the first
 | 
			
		||||
		 * parameter. DSNs must have this prototype:
 | 
			
		||||
		 * $dsn = 'driver://username:password@hostname/database';
 | 
			
		||||
		 */
 | 
			
		||||
		if (($dsn = @parse_url($params)) === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			show_error('Invalid DB Connection String');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$params = array(
 | 
			
		||||
			'dbdriver'	=> $dsn['scheme'],
 | 
			
		||||
			'hostname'	=> isset($dsn['host']) ? rawurldecode($dsn['host']) : '',
 | 
			
		||||
			'port'		=> isset($dsn['port']) ? rawurldecode($dsn['port']) : '',
 | 
			
		||||
			'username'	=> isset($dsn['user']) ? rawurldecode($dsn['user']) : '',
 | 
			
		||||
			'password'	=> isset($dsn['pass']) ? rawurldecode($dsn['pass']) : '',
 | 
			
		||||
			'database'	=> isset($dsn['path']) ? rawurldecode(substr($dsn['path'], 1)) : ''
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		// Were additional config items set?
 | 
			
		||||
		if (isset($dsn['query']))
 | 
			
		||||
		{
 | 
			
		||||
			parse_str($dsn['query'], $extra);
 | 
			
		||||
 | 
			
		||||
			foreach ($extra as $key => $val)
 | 
			
		||||
			{
 | 
			
		||||
				if (is_string($val) && in_array(strtoupper($val), array('TRUE', 'FALSE', 'NULL')))
 | 
			
		||||
				{
 | 
			
		||||
					$val = var_export($val, TRUE);
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				$params[$key] = $val;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// No DB specified yet? Beat them senseless...
 | 
			
		||||
	if (empty($params['dbdriver']))
 | 
			
		||||
	{
 | 
			
		||||
		show_error('You have not selected a database type to connect to.');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Load the DB classes. Note: Since the query builder class is optional
 | 
			
		||||
	// we need to dynamically create a class that extends proper parent class
 | 
			
		||||
	// based on whether we're using the query builder class or not.
 | 
			
		||||
	if ($query_builder_override !== NULL)
 | 
			
		||||
	{
 | 
			
		||||
		$query_builder = $query_builder_override;
 | 
			
		||||
	}
 | 
			
		||||
	// Backwards compatibility work-around for keeping the
 | 
			
		||||
	// $active_record config variable working. Should be
 | 
			
		||||
	// removed in v3.1
 | 
			
		||||
	elseif ( ! isset($query_builder) && isset($active_record))
 | 
			
		||||
	{
 | 
			
		||||
		$query_builder = $active_record;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	require_once(BASEPATH.'database/DB_driver.php');
 | 
			
		||||
 | 
			
		||||
	if ( ! isset($query_builder) OR $query_builder === TRUE)
 | 
			
		||||
	{
 | 
			
		||||
		require_once(BASEPATH.'database/DB_query_builder.php');
 | 
			
		||||
		if ( ! class_exists('CI_DB', FALSE))
 | 
			
		||||
		{
 | 
			
		||||
			/**
 | 
			
		||||
			 * CI_DB
 | 
			
		||||
			 *
 | 
			
		||||
			 * Acts as an alias for both CI_DB_driver and CI_DB_query_builder.
 | 
			
		||||
			 *
 | 
			
		||||
			 * @see	CI_DB_query_builder
 | 
			
		||||
			 * @see	CI_DB_driver
 | 
			
		||||
			 */
 | 
			
		||||
			class CI_DB extends CI_DB_query_builder { }
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	elseif ( ! class_exists('CI_DB', FALSE))
 | 
			
		||||
	{
 | 
			
		||||
		/**
 | 
			
		||||
		 * @ignore
 | 
			
		||||
		 */
 | 
			
		||||
		class CI_DB extends CI_DB_driver { }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Load the DB driver
 | 
			
		||||
	$driver_file = BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php';
 | 
			
		||||
 | 
			
		||||
	file_exists($driver_file) OR show_error('Invalid DB driver');
 | 
			
		||||
	require_once($driver_file);
 | 
			
		||||
 | 
			
		||||
	// Instantiate the DB adapter
 | 
			
		||||
	$driver = 'CI_DB_'.$params['dbdriver'].'_driver';
 | 
			
		||||
	$DB = new $driver($params);
 | 
			
		||||
 | 
			
		||||
	// Check for a subdriver
 | 
			
		||||
	if ( ! empty($DB->subdriver))
 | 
			
		||||
	{
 | 
			
		||||
		$driver_file = BASEPATH.'database/drivers/'.$DB->dbdriver.'/subdrivers/'.$DB->dbdriver.'_'.$DB->subdriver.'_driver.php';
 | 
			
		||||
 | 
			
		||||
		if (file_exists($driver_file))
 | 
			
		||||
		{
 | 
			
		||||
			require_once($driver_file);
 | 
			
		||||
			$driver = 'CI_DB_'.$DB->dbdriver.'_'.$DB->subdriver.'_driver';
 | 
			
		||||
			$DB = new $driver($params);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	$DB->initialize();
 | 
			
		||||
	return $DB;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										222
									
								
								system/database/DB_cache.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										222
									
								
								system/database/DB_cache.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,222 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Database Cache Class
 | 
			
		||||
 *
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_Cache {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * CI Singleton
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	object
 | 
			
		||||
	 */
 | 
			
		||||
	public $CI;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Database object
 | 
			
		||||
	 *
 | 
			
		||||
	 * Allows passing of DB object so that multiple database connections
 | 
			
		||||
	 * and returned DB objects can be supported.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	object
 | 
			
		||||
	 */
 | 
			
		||||
	public $db;
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Constructor
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	object	&$db
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct(&$db)
 | 
			
		||||
	{
 | 
			
		||||
		// Assign the main CI object to $this->CI and load the file helper since we use it a lot
 | 
			
		||||
		$this->CI =& get_instance();
 | 
			
		||||
		$this->db =& $db;
 | 
			
		||||
		$this->CI->load->helper('file');
 | 
			
		||||
 | 
			
		||||
		$this->check_path();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Set Cache Directory Path
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$path	Path to the cache directory
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public function check_path($path = '')
 | 
			
		||||
	{
 | 
			
		||||
		if ($path === '')
 | 
			
		||||
		{
 | 
			
		||||
			if ($this->db->cachedir === '')
 | 
			
		||||
			{
 | 
			
		||||
				return $this->db->cache_off();
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$path = $this->db->cachedir;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Add a trailing slash to the path if needed
 | 
			
		||||
		$path = realpath($path)
 | 
			
		||||
			? rtrim(realpath($path), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR
 | 
			
		||||
			: rtrim($path, '/').'/';
 | 
			
		||||
 | 
			
		||||
		if ( ! is_dir($path))
 | 
			
		||||
		{
 | 
			
		||||
			log_message('debug', 'DB cache path error: '.$path);
 | 
			
		||||
 | 
			
		||||
			// If the path is wrong we'll turn off caching
 | 
			
		||||
			return $this->db->cache_off();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! is_really_writable($path))
 | 
			
		||||
		{
 | 
			
		||||
			log_message('debug', 'DB cache dir not writable: '.$path);
 | 
			
		||||
 | 
			
		||||
			// If the path is not really writable we'll turn off caching
 | 
			
		||||
			return $this->db->cache_off();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->db->cachedir = $path;
 | 
			
		||||
		return TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Retrieve a cached query
 | 
			
		||||
	 *
 | 
			
		||||
	 * The URI being requested will become the name of the cache sub-folder.
 | 
			
		||||
	 * An MD5 hash of the SQL statement will become the cache file name.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$sql
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	public function read($sql)
 | 
			
		||||
	{
 | 
			
		||||
		$segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
 | 
			
		||||
		$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
 | 
			
		||||
		$filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql);
 | 
			
		||||
 | 
			
		||||
		if ( ! is_file($filepath) OR FALSE === ($cachedata = file_get_contents($filepath)))
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return unserialize($cachedata);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Write a query to a cache file
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$sql
 | 
			
		||||
	 * @param	object	$object
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public function write($sql, $object)
 | 
			
		||||
	{
 | 
			
		||||
		$segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
 | 
			
		||||
		$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
 | 
			
		||||
		$dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';
 | 
			
		||||
		$filename = md5($sql);
 | 
			
		||||
 | 
			
		||||
		if ( ! is_dir($dir_path) && ! @mkdir($dir_path, 0750))
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (write_file($dir_path.$filename, serialize($object)) === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		chmod($dir_path.$filename, 0640);
 | 
			
		||||
		return TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Delete cache files within a particular directory
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$segment_one
 | 
			
		||||
	 * @param	string	$segment_two
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function delete($segment_one = '', $segment_two = '')
 | 
			
		||||
	{
 | 
			
		||||
		if ($segment_one === '')
 | 
			
		||||
		{
 | 
			
		||||
			$segment_one  = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($segment_two === '')
 | 
			
		||||
		{
 | 
			
		||||
			$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';
 | 
			
		||||
		delete_files($dir_path, TRUE);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Delete all existing cache files
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function delete_all()
 | 
			
		||||
	{
 | 
			
		||||
		delete_files($this->db->cachedir, TRUE, TRUE);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1999
									
								
								system/database/DB_driver.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1999
									
								
								system/database/DB_driver.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1034
									
								
								system/database/DB_forge.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1034
									
								
								system/database/DB_forge.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										2809
									
								
								system/database/DB_query_builder.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2809
									
								
								system/database/DB_query_builder.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										666
									
								
								system/database/DB_result.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										666
									
								
								system/database/DB_result.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										425
									
								
								system/database/DB_utility.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										425
									
								
								system/database/DB_utility.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,425 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Database Utility Class
 | 
			
		||||
 *
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
abstract class CI_DB_utility {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Database object
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	object
 | 
			
		||||
	 */
 | 
			
		||||
	protected $db;
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List databases statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_list_databases		= FALSE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * OPTIMIZE TABLE statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_optimize_table	= FALSE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * REPAIR TABLE statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_repair_table	= FALSE;
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Class constructor
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	object	&$db	Database object
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct(&$db)
 | 
			
		||||
	{
 | 
			
		||||
		$this->db =& $db;
 | 
			
		||||
		log_message('info', 'Database Utility Class Initialized');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List databases
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function list_databases()
 | 
			
		||||
	{
 | 
			
		||||
		// Is there a cached result?
 | 
			
		||||
		if (isset($this->db->data_cache['db_names']))
 | 
			
		||||
		{
 | 
			
		||||
			return $this->db->data_cache['db_names'];
 | 
			
		||||
		}
 | 
			
		||||
		elseif ($this->_list_databases === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->db->data_cache['db_names'] = array();
 | 
			
		||||
 | 
			
		||||
		$query = $this->db->query($this->_list_databases);
 | 
			
		||||
		if ($query === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			return $this->db->data_cache['db_names'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for ($i = 0, $query = $query->result_array(), $c = count($query); $i < $c; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			$this->db->data_cache['db_names'][] = current($query[$i]);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $this->db->data_cache['db_names'];
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Determine if a particular database exists
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$database_name
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public function database_exists($database_name)
 | 
			
		||||
	{
 | 
			
		||||
		return in_array($database_name, $this->list_databases());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Optimize Table
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table_name
 | 
			
		||||
	 * @return	mixed
 | 
			
		||||
	 */
 | 
			
		||||
	public function optimize_table($table_name)
 | 
			
		||||
	{
 | 
			
		||||
		if ($this->_optimize_table === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$query = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name)));
 | 
			
		||||
		if ($query !== FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			$query = $query->result_array();
 | 
			
		||||
			return current($query);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return FALSE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Optimize Database
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	mixed
 | 
			
		||||
	 */
 | 
			
		||||
	public function optimize_database()
 | 
			
		||||
	{
 | 
			
		||||
		if ($this->_optimize_table === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$result = array();
 | 
			
		||||
		foreach ($this->db->list_tables() as $table_name)
 | 
			
		||||
		{
 | 
			
		||||
			$res = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name)));
 | 
			
		||||
			if (is_bool($res))
 | 
			
		||||
			{
 | 
			
		||||
				return $res;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// Build the result array...
 | 
			
		||||
			$res = $res->result_array();
 | 
			
		||||
			$res = current($res);
 | 
			
		||||
			$key = str_replace($this->db->database.'.', '', current($res));
 | 
			
		||||
			$keys = array_keys($res);
 | 
			
		||||
			unset($res[$keys[0]]);
 | 
			
		||||
 | 
			
		||||
			$result[$key] = $res;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $result;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Repair Table
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table_name
 | 
			
		||||
	 * @return	mixed
 | 
			
		||||
	 */
 | 
			
		||||
	public function repair_table($table_name)
 | 
			
		||||
	{
 | 
			
		||||
		if ($this->_repair_table === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$query = $this->db->query(sprintf($this->_repair_table, $this->db->escape_identifiers($table_name)));
 | 
			
		||||
		if (is_bool($query))
 | 
			
		||||
		{
 | 
			
		||||
			return $query;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$query = $query->result_array();
 | 
			
		||||
		return current($query);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Generate CSV from a query result object
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	object	$query		Query result object
 | 
			
		||||
	 * @param	string	$delim		Delimiter (default: ,)
 | 
			
		||||
	 * @param	string	$newline	Newline character (default: \n)
 | 
			
		||||
	 * @param	string	$enclosure	Enclosure (default: ")
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	public function csv_from_result($query, $delim = ',', $newline = "\n", $enclosure = '"')
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
 | 
			
		||||
		{
 | 
			
		||||
			show_error('You must submit a valid result object');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$out = '';
 | 
			
		||||
		// First generate the headings from the table column names
 | 
			
		||||
		foreach ($query->list_fields() as $name)
 | 
			
		||||
		{
 | 
			
		||||
			$out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$out = substr($out, 0, -strlen($delim)).$newline;
 | 
			
		||||
 | 
			
		||||
		// Next blast through the result array and build out the rows
 | 
			
		||||
		while ($row = $query->unbuffered_row('array'))
 | 
			
		||||
		{
 | 
			
		||||
			$line = array();
 | 
			
		||||
			foreach ($row as $item)
 | 
			
		||||
			{
 | 
			
		||||
				$line[] = $enclosure.str_replace($enclosure, $enclosure.$enclosure, (string) $item).$enclosure;
 | 
			
		||||
			}
 | 
			
		||||
			$out .= implode($delim, $line).$newline;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $out;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Generate XML data from a query result object
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	object	$query	Query result object
 | 
			
		||||
	 * @param	array	$params	Any preferences
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	public function xml_from_result($query, $params = array())
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
 | 
			
		||||
		{
 | 
			
		||||
			show_error('You must submit a valid result object');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Set our default values
 | 
			
		||||
		foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => $val)
 | 
			
		||||
		{
 | 
			
		||||
			if ( ! isset($params[$key]))
 | 
			
		||||
			{
 | 
			
		||||
				$params[$key] = $val;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Create variables for convenience
 | 
			
		||||
		extract($params);
 | 
			
		||||
 | 
			
		||||
		// Load the xml helper
 | 
			
		||||
		get_instance()->load->helper('xml');
 | 
			
		||||
 | 
			
		||||
		// Generate the result
 | 
			
		||||
		$xml = '<'.$root.'>'.$newline;
 | 
			
		||||
		while ($row = $query->unbuffered_row())
 | 
			
		||||
		{
 | 
			
		||||
			$xml .= $tab.'<'.$element.'>'.$newline;
 | 
			
		||||
			foreach ($row as $key => $val)
 | 
			
		||||
			{
 | 
			
		||||
				$xml .= $tab.$tab.'<'.$key.'>'.xml_convert($val).'</'.$key.'>'.$newline;
 | 
			
		||||
			}
 | 
			
		||||
			$xml .= $tab.'</'.$element.'>'.$newline;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $xml.'</'.$root.'>'.$newline;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Database Backup
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	$params
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	public function backup($params = array())
 | 
			
		||||
	{
 | 
			
		||||
		// If the parameters have not been submitted as an
 | 
			
		||||
		// array then we know that it is simply the table
 | 
			
		||||
		// name, which is a valid short cut.
 | 
			
		||||
		if (is_string($params))
 | 
			
		||||
		{
 | 
			
		||||
			$params = array('tables' => $params);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Set up our default preferences
 | 
			
		||||
		$prefs = array(
 | 
			
		||||
			'tables'		=> array(),
 | 
			
		||||
			'ignore'		=> array(),
 | 
			
		||||
			'filename'		=> '',
 | 
			
		||||
			'format'		=> 'gzip', // gzip, zip, txt
 | 
			
		||||
			'add_drop'		=> TRUE,
 | 
			
		||||
			'add_insert'		=> TRUE,
 | 
			
		||||
			'newline'		=> "\n",
 | 
			
		||||
			'foreign_key_checks'	=> TRUE
 | 
			
		||||
		);
 | 
			
		||||
 | 
			
		||||
		// Did the user submit any preferences? If so set them....
 | 
			
		||||
		if (count($params) > 0)
 | 
			
		||||
		{
 | 
			
		||||
			foreach ($prefs as $key => $val)
 | 
			
		||||
			{
 | 
			
		||||
				if (isset($params[$key]))
 | 
			
		||||
				{
 | 
			
		||||
					$prefs[$key] = $params[$key];
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Are we backing up a complete database or individual tables?
 | 
			
		||||
		// If no table names were submitted we'll fetch the entire table list
 | 
			
		||||
		if (count($prefs['tables']) === 0)
 | 
			
		||||
		{
 | 
			
		||||
			$prefs['tables'] = $this->db->list_tables();
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Validate the format
 | 
			
		||||
		if ( ! in_array($prefs['format'], array('gzip', 'zip', 'txt'), TRUE))
 | 
			
		||||
		{
 | 
			
		||||
			$prefs['format'] = 'txt';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Is the encoder supported? If not, we'll either issue an
 | 
			
		||||
		// error or use plain text depending on the debug settings
 | 
			
		||||
		if (($prefs['format'] === 'gzip' && ! function_exists('gzencode'))
 | 
			
		||||
			OR ($prefs['format'] === 'zip' && ! function_exists('gzcompress')))
 | 
			
		||||
		{
 | 
			
		||||
			if ($this->db->db_debug)
 | 
			
		||||
			{
 | 
			
		||||
				return $this->db->display_error('db_unsupported_compression');
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$prefs['format'] = 'txt';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Was a Zip file requested?
 | 
			
		||||
		if ($prefs['format'] === 'zip')
 | 
			
		||||
		{
 | 
			
		||||
			// Set the filename if not provided (only needed with Zip files)
 | 
			
		||||
			if ($prefs['filename'] === '')
 | 
			
		||||
			{
 | 
			
		||||
				$prefs['filename'] = (count($prefs['tables']) === 1 ? $prefs['tables'] : $this->db->database)
 | 
			
		||||
							.date('Y-m-d_H-i', time()).'.sql';
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				// If they included the .zip file extension we'll remove it
 | 
			
		||||
				if (preg_match('|.+?\.zip$|', $prefs['filename']))
 | 
			
		||||
				{
 | 
			
		||||
					$prefs['filename'] = str_replace('.zip', '', $prefs['filename']);
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				// Tack on the ".sql" file extension if needed
 | 
			
		||||
				if ( ! preg_match('|.+?\.sql$|', $prefs['filename']))
 | 
			
		||||
				{
 | 
			
		||||
					$prefs['filename'] .= '.sql';
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// Load the Zip class and output it
 | 
			
		||||
			$CI =& get_instance();
 | 
			
		||||
			$CI->load->library('zip');
 | 
			
		||||
			$CI->zip->add_data($prefs['filename'], $this->_backup($prefs));
 | 
			
		||||
			return $CI->zip->get_zip();
 | 
			
		||||
		}
 | 
			
		||||
		elseif ($prefs['format'] === 'txt') // Was a text file requested?
 | 
			
		||||
		{
 | 
			
		||||
			return $this->_backup($prefs);
 | 
			
		||||
		}
 | 
			
		||||
		elseif ($prefs['format'] === 'gzip') // Was a Gzip file requested?
 | 
			
		||||
		{
 | 
			
		||||
			return gzencode($this->_backup($prefs));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										406
									
								
								system/database/drivers/cubrid/cubrid_driver.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										406
									
								
								system/database/drivers/cubrid/cubrid_driver.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,406 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 2.1.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * CUBRID Database Adapter Class
 | 
			
		||||
 *
 | 
			
		||||
 * Note: _DB is an extender class that the app controller
 | 
			
		||||
 * creates dynamically based on whether the query builder
 | 
			
		||||
 * class is being used or not.
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Drivers
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		Esen Sagynov
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_cubrid_driver extends CI_DB {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Database driver
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	public $dbdriver = 'cubrid';
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Auto-commit flag
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public $auto_commit = TRUE;
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Identifier escape character
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_escape_char = '`';
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * ORDER BY random keyword
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_random_keyword = array('RANDOM()', 'RANDOM(%d)');
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Class constructor
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	$params
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct($params)
 | 
			
		||||
	{
 | 
			
		||||
		parent::__construct($params);
 | 
			
		||||
 | 
			
		||||
		if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:[^:]*:[^:]*:(\?.+)?$/', $this->dsn, $matches))
 | 
			
		||||
		{
 | 
			
		||||
			if (stripos($matches[2], 'autocommit=off') !== FALSE)
 | 
			
		||||
			{
 | 
			
		||||
				$this->auto_commit = FALSE;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			// If no port is defined by the user, use the default value
 | 
			
		||||
			empty($this->port) OR $this->port = 33000;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Non-persistent database connection
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	bool	$persistent
 | 
			
		||||
	 * @return	resource
 | 
			
		||||
	 */
 | 
			
		||||
	public function db_connect($persistent = FALSE)
 | 
			
		||||
	{
 | 
			
		||||
		if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:([^:]*):([^:]*):(\?.+)?$/', $this->dsn, $matches))
 | 
			
		||||
		{
 | 
			
		||||
			$func = ($persistent !== TRUE) ? 'cubrid_connect_with_url' : 'cubrid_pconnect_with_url';
 | 
			
		||||
			return ($matches[2] === '' && $matches[3] === '' && $this->username !== '' && $this->password !== '')
 | 
			
		||||
				? $func($this->dsn, $this->username, $this->password)
 | 
			
		||||
				: $func($this->dsn);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$func = ($persistent !== TRUE) ? 'cubrid_connect' : 'cubrid_pconnect';
 | 
			
		||||
		return ($this->username !== '')
 | 
			
		||||
			? $func($this->hostname, $this->port, $this->database, $this->username, $this->password)
 | 
			
		||||
			: $func($this->hostname, $this->port, $this->database);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Reconnect
 | 
			
		||||
	 *
 | 
			
		||||
	 * Keep / reestablish the db connection if no queries have been
 | 
			
		||||
	 * sent for a length of time exceeding the server's idle timeout
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function reconnect()
 | 
			
		||||
	{
 | 
			
		||||
		if (cubrid_ping($this->conn_id) === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			$this->conn_id = FALSE;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Database version number
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	public function version()
 | 
			
		||||
	{
 | 
			
		||||
		if (isset($this->data_cache['version']))
 | 
			
		||||
		{
 | 
			
		||||
			return $this->data_cache['version'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return ( ! $this->conn_id OR ($version = cubrid_get_server_info($this->conn_id)) === FALSE)
 | 
			
		||||
			? FALSE
 | 
			
		||||
			: $this->data_cache['version'] = $version;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Execute the query
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$sql	an SQL query
 | 
			
		||||
	 * @return	resource
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _execute($sql)
 | 
			
		||||
	{
 | 
			
		||||
		return cubrid_query($sql, $this->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Begin Transaction
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _trans_begin()
 | 
			
		||||
	{
 | 
			
		||||
		if (($autocommit = cubrid_get_autocommit($this->conn_id)) === NULL)
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
		elseif ($autocommit === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			return cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_FALSE);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Commit Transaction
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _trans_commit()
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! cubrid_commit($this->conn_id))
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
 | 
			
		||||
		{
 | 
			
		||||
			return cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Rollback Transaction
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _trans_rollback()
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! cubrid_rollback($this->conn_id))
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
 | 
			
		||||
		{
 | 
			
		||||
			cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Platform-dependent string escape
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _escape_str($str)
 | 
			
		||||
	{
 | 
			
		||||
		return cubrid_real_escape_string($str, $this->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Affected Rows
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	public function affected_rows()
 | 
			
		||||
	{
 | 
			
		||||
		return cubrid_affected_rows();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Insert ID
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	public function insert_id()
 | 
			
		||||
	{
 | 
			
		||||
		return cubrid_insert_id($this->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List table query
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates a platform-specific query string so that the table names can be fetched
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	bool	$prefix_limit
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _list_tables($prefix_limit = FALSE)
 | 
			
		||||
	{
 | 
			
		||||
		$sql = 'SHOW TABLES';
 | 
			
		||||
 | 
			
		||||
		if ($prefix_limit !== FALSE && $this->dbprefix !== '')
 | 
			
		||||
		{
 | 
			
		||||
			return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'";
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $sql;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Show column query
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates a platform-specific query string so that the column names can be fetched
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _list_columns($table = '')
 | 
			
		||||
	{
 | 
			
		||||
		return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Returns an object with field data
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function field_data($table)
 | 
			
		||||
	{
 | 
			
		||||
		if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
		$query = $query->result_object();
 | 
			
		||||
 | 
			
		||||
		$retval = array();
 | 
			
		||||
		for ($i = 0, $c = count($query); $i < $c; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			$retval[$i]			= new stdClass();
 | 
			
		||||
			$retval[$i]->name		= $query[$i]->Field;
 | 
			
		||||
 | 
			
		||||
			sscanf($query[$i]->Type, '%[a-z](%d)',
 | 
			
		||||
				$retval[$i]->type,
 | 
			
		||||
				$retval[$i]->max_length
 | 
			
		||||
			);
 | 
			
		||||
 | 
			
		||||
			$retval[$i]->default		= $query[$i]->Default;
 | 
			
		||||
			$retval[$i]->primary_key	= (int) ($query[$i]->Key === 'PRI');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $retval;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Error
 | 
			
		||||
	 *
 | 
			
		||||
	 * Returns an array containing code and message of the last
 | 
			
		||||
	 * database error that has occurred.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function error()
 | 
			
		||||
	{
 | 
			
		||||
		return array('code' => cubrid_errno($this->conn_id), 'message' => cubrid_error($this->conn_id));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * FROM tables
 | 
			
		||||
	 *
 | 
			
		||||
	 * Groups tables in FROM clauses if needed, so there is no confusion
 | 
			
		||||
	 * about operator precedence.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _from_tables()
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! empty($this->qb_join) && count($this->qb_from) > 1)
 | 
			
		||||
		{
 | 
			
		||||
			return '('.implode(', ', $this->qb_from).')';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return implode(', ', $this->qb_from);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Close DB Connection
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _close()
 | 
			
		||||
	{
 | 
			
		||||
		cubrid_close($this->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										231
									
								
								system/database/drivers/cubrid/cubrid_forge.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										231
									
								
								system/database/drivers/cubrid/cubrid_forge.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,231 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 2.1.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * CUBRID Forge Class
 | 
			
		||||
 *
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		Esen Sagynov
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_cubrid_forge extends CI_DB_forge {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * CREATE DATABASE statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_create_database	= FALSE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * CREATE TABLE keys flag
 | 
			
		||||
	 *
 | 
			
		||||
	 * Whether table keys are created from within the
 | 
			
		||||
	 * CREATE TABLE statement.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_create_table_keys	= TRUE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * DROP DATABASE statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_drop_database	= FALSE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * CREATE TABLE IF statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_create_table_if	= FALSE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * UNSIGNED support
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_unsigned		= array(
 | 
			
		||||
		'SHORT'		=> 'INTEGER',
 | 
			
		||||
		'SMALLINT'	=> 'INTEGER',
 | 
			
		||||
		'INT'		=> 'BIGINT',
 | 
			
		||||
		'INTEGER'	=> 'BIGINT',
 | 
			
		||||
		'BIGINT'	=> 'NUMERIC',
 | 
			
		||||
		'FLOAT'		=> 'DOUBLE',
 | 
			
		||||
		'REAL'		=> 'DOUBLE'
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * ALTER TABLE
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$alter_type	ALTER type
 | 
			
		||||
	 * @param	string	$table		Table name
 | 
			
		||||
	 * @param	mixed	$field		Column definition
 | 
			
		||||
	 * @return	string|string[]
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _alter_table($alter_type, $table, $field)
 | 
			
		||||
	{
 | 
			
		||||
		if (in_array($alter_type, array('DROP', 'ADD'), TRUE))
 | 
			
		||||
		{
 | 
			
		||||
			return parent::_alter_table($alter_type, $table, $field);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table);
 | 
			
		||||
		$sqls = array();
 | 
			
		||||
		for ($i = 0, $c = count($field); $i < $c; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			if ($field[$i]['_literal'] !== FALSE)
 | 
			
		||||
			{
 | 
			
		||||
				$sqls[] = $sql.' CHANGE '.$field[$i]['_literal'];
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				$alter_type = empty($field[$i]['new_name']) ? ' MODIFY ' : ' CHANGE ';
 | 
			
		||||
				$sqls[] = $sql.$alter_type.$this->_process_column($field[$i]);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $sqls;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Process column
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	$field
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _process_column($field)
 | 
			
		||||
	{
 | 
			
		||||
		$extra_clause = isset($field['after'])
 | 
			
		||||
			? ' AFTER '.$this->db->escape_identifiers($field['after']) : '';
 | 
			
		||||
 | 
			
		||||
		if (empty($extra_clause) && isset($field['first']) && $field['first'] === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			$extra_clause = ' FIRST';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $this->db->escape_identifiers($field['name'])
 | 
			
		||||
			.(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
 | 
			
		||||
			.' '.$field['type'].$field['length']
 | 
			
		||||
			.$field['unsigned']
 | 
			
		||||
			.$field['null']
 | 
			
		||||
			.$field['default']
 | 
			
		||||
			.$field['auto_increment']
 | 
			
		||||
			.$field['unique']
 | 
			
		||||
			.$extra_clause;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Field attribute TYPE
 | 
			
		||||
	 *
 | 
			
		||||
	 * Performs a data type mapping between different databases.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	&$attributes
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _attr_type(&$attributes)
 | 
			
		||||
	{
 | 
			
		||||
		switch (strtoupper($attributes['TYPE']))
 | 
			
		||||
		{
 | 
			
		||||
			case 'TINYINT':
 | 
			
		||||
				$attributes['TYPE'] = 'SMALLINT';
 | 
			
		||||
				$attributes['UNSIGNED'] = FALSE;
 | 
			
		||||
				return;
 | 
			
		||||
			case 'MEDIUMINT':
 | 
			
		||||
				$attributes['TYPE'] = 'INTEGER';
 | 
			
		||||
				$attributes['UNSIGNED'] = FALSE;
 | 
			
		||||
				return;
 | 
			
		||||
			case 'LONGTEXT':
 | 
			
		||||
				$attributes['TYPE'] = 'STRING';
 | 
			
		||||
				return;
 | 
			
		||||
			default: return;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Process indexes
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table	(ignored)
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _process_indexes($table)
 | 
			
		||||
	{
 | 
			
		||||
		$sql = '';
 | 
			
		||||
 | 
			
		||||
		for ($i = 0, $c = count($this->keys); $i < $c; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			if (is_array($this->keys[$i]))
 | 
			
		||||
			{
 | 
			
		||||
				for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++)
 | 
			
		||||
				{
 | 
			
		||||
					if ( ! isset($this->fields[$this->keys[$i][$i2]]))
 | 
			
		||||
					{
 | 
			
		||||
						unset($this->keys[$i][$i2]);
 | 
			
		||||
						continue;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			elseif ( ! isset($this->fields[$this->keys[$i]]))
 | 
			
		||||
			{
 | 
			
		||||
				unset($this->keys[$i]);
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			is_array($this->keys[$i]) OR $this->keys[$i] = array($this->keys[$i]);
 | 
			
		||||
 | 
			
		||||
			$sql .= ",\n\tKEY ".$this->db->escape_identifiers(implode('_', $this->keys[$i]))
 | 
			
		||||
				.' ('.implode(', ', $this->db->escape_identifiers($this->keys[$i])).')';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->keys = array();
 | 
			
		||||
 | 
			
		||||
		return $sql;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										178
									
								
								system/database/drivers/cubrid/cubrid_result.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										178
									
								
								system/database/drivers/cubrid/cubrid_result.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,178 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 2.1.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * CUBRID Result Class
 | 
			
		||||
 *
 | 
			
		||||
 * This class extends the parent result class: CI_DB_result
 | 
			
		||||
 *
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		Esen Sagynov
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_cubrid_result extends CI_DB_result {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Number of rows in the result set
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	public function num_rows()
 | 
			
		||||
	{
 | 
			
		||||
		return is_int($this->num_rows)
 | 
			
		||||
			? $this->num_rows
 | 
			
		||||
			: $this->num_rows = cubrid_num_rows($this->result_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Number of fields in the result set
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	public function num_fields()
 | 
			
		||||
	{
 | 
			
		||||
		return cubrid_num_fields($this->result_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Fetch Field Names
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates an array of column names
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function list_fields()
 | 
			
		||||
	{
 | 
			
		||||
		return cubrid_column_names($this->result_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Field data
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates an array of objects containing field meta-data
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function field_data()
 | 
			
		||||
	{
 | 
			
		||||
		$retval = array();
 | 
			
		||||
 | 
			
		||||
		for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			$retval[$i]			= new stdClass();
 | 
			
		||||
			$retval[$i]->name		= cubrid_field_name($this->result_id, $i);
 | 
			
		||||
			$retval[$i]->type		= cubrid_field_type($this->result_id, $i);
 | 
			
		||||
			$retval[$i]->max_length		= cubrid_field_len($this->result_id, $i);
 | 
			
		||||
			$retval[$i]->primary_key	= (int) (strpos(cubrid_field_flags($this->result_id, $i), 'primary_key') !== FALSE);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $retval;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Free the result
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function free_result()
 | 
			
		||||
	{
 | 
			
		||||
		if (is_resource($this->result_id) OR
 | 
			
		||||
			(get_resource_type($this->result_id) === 'Unknown' && preg_match('/Resource id #/', strval($this->result_id))))
 | 
			
		||||
		{
 | 
			
		||||
			cubrid_close_request($this->result_id);
 | 
			
		||||
			$this->result_id = FALSE;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Data Seek
 | 
			
		||||
	 *
 | 
			
		||||
	 * Moves the internal pointer to the desired offset. We call
 | 
			
		||||
	 * this internally before fetching results to make sure the
 | 
			
		||||
	 * result set starts at zero.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	int	$n
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public function data_seek($n = 0)
 | 
			
		||||
	{
 | 
			
		||||
		return cubrid_data_seek($this->result_id, $n);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Result - associative array
 | 
			
		||||
	 *
 | 
			
		||||
	 * Returns the result set as an array
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _fetch_assoc()
 | 
			
		||||
	{
 | 
			
		||||
		return cubrid_fetch_assoc($this->result_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Result - object
 | 
			
		||||
	 *
 | 
			
		||||
	 * Returns the result set as an object
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$class_name
 | 
			
		||||
	 * @return	object
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _fetch_object($class_name = 'stdClass')
 | 
			
		||||
	{
 | 
			
		||||
		return cubrid_fetch_object($this->result_id, $class_name);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										80
									
								
								system/database/drivers/cubrid/cubrid_utility.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										80
									
								
								system/database/drivers/cubrid/cubrid_utility.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,80 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 2.1.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * CUBRID Utility Class
 | 
			
		||||
 *
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		Esen Sagynov
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_cubrid_utility extends CI_DB_utility {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List databases
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function list_databases()
 | 
			
		||||
	{
 | 
			
		||||
		if (isset($this->db->data_cache['db_names']))
 | 
			
		||||
		{
 | 
			
		||||
			return $this->db->data_cache['db_names'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $this->db->data_cache['db_names'] = cubrid_list_dbs($this->db->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * CUBRID Export
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	Preferences
 | 
			
		||||
	 * @return	mixed
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _backup($params = array())
 | 
			
		||||
	{
 | 
			
		||||
		// No SQL based support in CUBRID as of version 8.4.0. Database or
 | 
			
		||||
		// table backup can be performed using CUBRID Manager
 | 
			
		||||
		// database administration tool.
 | 
			
		||||
		return $this->db->display_error('db_unsupported_feature');
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								system/database/drivers/cubrid/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								system/database/drivers/cubrid/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
	<title>403 Forbidden</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<p>Directory access is forbidden.</p>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										414
									
								
								system/database/drivers/ibase/ibase_driver.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										414
									
								
								system/database/drivers/ibase/ibase_driver.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,414 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 3.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Firebird/Interbase Database Adapter Class
 | 
			
		||||
 *
 | 
			
		||||
 * Note: _DB is an extender class that the app controller
 | 
			
		||||
 * creates dynamically based on whether the query builder
 | 
			
		||||
 * class is being used or not.
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Drivers
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_ibase_driver extends CI_DB {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Database driver
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	public $dbdriver = 'ibase';
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * ORDER BY random keyword
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_random_keyword = array('RAND()', 'RAND()');
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * IBase Transaction status flag
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	resource
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_ibase_trans;
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Non-persistent database connection
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	bool	$persistent
 | 
			
		||||
	 * @return	resource
 | 
			
		||||
	 */
 | 
			
		||||
	public function db_connect($persistent = FALSE)
 | 
			
		||||
	{
 | 
			
		||||
		return ($persistent === TRUE)
 | 
			
		||||
			? ibase_pconnect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set)
 | 
			
		||||
			: ibase_connect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Database version number
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	public function version()
 | 
			
		||||
	{
 | 
			
		||||
		if (isset($this->data_cache['version']))
 | 
			
		||||
		{
 | 
			
		||||
			return $this->data_cache['version'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (($service = ibase_service_attach($this->hostname, $this->username, $this->password)))
 | 
			
		||||
		{
 | 
			
		||||
			$this->data_cache['version'] = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
 | 
			
		||||
 | 
			
		||||
			// Don't keep the service open
 | 
			
		||||
			ibase_service_detach($service);
 | 
			
		||||
			return $this->data_cache['version'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return FALSE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Execute the query
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$sql	an SQL query
 | 
			
		||||
	 * @return	resource
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _execute($sql)
 | 
			
		||||
	{
 | 
			
		||||
		return ibase_query(isset($this->_ibase_trans) ? $this->_ibase_trans : $this->conn_id, $sql);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Begin Transaction
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _trans_begin()
 | 
			
		||||
	{
 | 
			
		||||
		if (($trans_handle = ibase_trans($this->conn_id)) === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->_ibase_trans = $trans_handle;
 | 
			
		||||
		return TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Commit Transaction
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _trans_commit()
 | 
			
		||||
	{
 | 
			
		||||
		if (ibase_commit($this->_ibase_trans))
 | 
			
		||||
		{
 | 
			
		||||
			$this->_ibase_trans = NULL;
 | 
			
		||||
			return TRUE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return FALSE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Rollback Transaction
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _trans_rollback()
 | 
			
		||||
	{
 | 
			
		||||
		if (ibase_rollback($this->_ibase_trans))
 | 
			
		||||
		{
 | 
			
		||||
			$this->_ibase_trans = NULL;
 | 
			
		||||
			return TRUE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return FALSE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Affected Rows
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	public function affected_rows()
 | 
			
		||||
	{
 | 
			
		||||
		return ibase_affected_rows($this->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Insert ID
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$generator_name
 | 
			
		||||
	 * @param	int	$inc_by
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	public function insert_id($generator_name, $inc_by = 0)
 | 
			
		||||
	{
 | 
			
		||||
		//If a generator hasn't been used before it will return 0
 | 
			
		||||
		return ibase_gen_id('"'.$generator_name.'"', $inc_by);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List table query
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates a platform-specific query string so that the table names can be fetched
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	bool	$prefix_limit
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _list_tables($prefix_limit = FALSE)
 | 
			
		||||
	{
 | 
			
		||||
		$sql = 'SELECT TRIM("RDB$RELATION_NAME") AS TABLE_NAME FROM "RDB$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\'';
 | 
			
		||||
 | 
			
		||||
		if ($prefix_limit !== FALSE && $this->dbprefix !== '')
 | 
			
		||||
		{
 | 
			
		||||
			return $sql.' AND TRIM("RDB$RELATION_NAME") AS TABLE_NAME LIKE \''.$this->escape_like_str($this->dbprefix)."%' "
 | 
			
		||||
				.sprintf($this->_like_escape_str, $this->_like_escape_chr);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $sql;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Show column query
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates a platform-specific query string so that the column names can be fetched
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _list_columns($table = '')
 | 
			
		||||
	{
 | 
			
		||||
		return 'SELECT TRIM("RDB$FIELD_NAME") AS COLUMN_NAME FROM "RDB$RELATION_FIELDS" WHERE "RDB$RELATION_NAME" = '.$this->escape($table);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Returns an object with field data
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function field_data($table)
 | 
			
		||||
	{
 | 
			
		||||
		$sql = 'SELECT "rfields"."RDB$FIELD_NAME" AS "name",
 | 
			
		||||
				CASE "fields"."RDB$FIELD_TYPE"
 | 
			
		||||
					WHEN 7 THEN \'SMALLINT\'
 | 
			
		||||
					WHEN 8 THEN \'INTEGER\'
 | 
			
		||||
					WHEN 9 THEN \'QUAD\'
 | 
			
		||||
					WHEN 10 THEN \'FLOAT\'
 | 
			
		||||
					WHEN 11 THEN \'DFLOAT\'
 | 
			
		||||
					WHEN 12 THEN \'DATE\'
 | 
			
		||||
					WHEN 13 THEN \'TIME\'
 | 
			
		||||
					WHEN 14 THEN \'CHAR\'
 | 
			
		||||
					WHEN 16 THEN \'INT64\'
 | 
			
		||||
					WHEN 27 THEN \'DOUBLE\'
 | 
			
		||||
					WHEN 35 THEN \'TIMESTAMP\'
 | 
			
		||||
					WHEN 37 THEN \'VARCHAR\'
 | 
			
		||||
					WHEN 40 THEN \'CSTRING\'
 | 
			
		||||
					WHEN 261 THEN \'BLOB\'
 | 
			
		||||
					ELSE NULL
 | 
			
		||||
				END AS "type",
 | 
			
		||||
				"fields"."RDB$FIELD_LENGTH" AS "max_length",
 | 
			
		||||
				"rfields"."RDB$DEFAULT_VALUE" AS "default"
 | 
			
		||||
			FROM "RDB$RELATION_FIELDS" "rfields"
 | 
			
		||||
				JOIN "RDB$FIELDS" "fields" ON "rfields"."RDB$FIELD_SOURCE" = "fields"."RDB$FIELD_NAME"
 | 
			
		||||
			WHERE "rfields"."RDB$RELATION_NAME" = '.$this->escape($table).'
 | 
			
		||||
			ORDER BY "rfields"."RDB$FIELD_POSITION"';
 | 
			
		||||
 | 
			
		||||
		return (($query = $this->query($sql)) !== FALSE)
 | 
			
		||||
			? $query->result_object()
 | 
			
		||||
			: FALSE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Error
 | 
			
		||||
	 *
 | 
			
		||||
	 * Returns an array containing code and message of the last
 | 
			
		||||
	 * database error that has occurred.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function error()
 | 
			
		||||
	{
 | 
			
		||||
		return array('code' => ibase_errcode(), 'message' => ibase_errmsg());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Update statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates a platform-specific update string from the supplied data
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table
 | 
			
		||||
	 * @param	array	$values
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _update($table, $values)
 | 
			
		||||
	{
 | 
			
		||||
		$this->qb_limit = FALSE;
 | 
			
		||||
		return parent::_update($table, $values);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Truncate statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates a platform-specific truncate string from the supplied data
 | 
			
		||||
	 *
 | 
			
		||||
	 * If the database does not support the TRUNCATE statement,
 | 
			
		||||
	 * then this method maps to 'DELETE FROM table'
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _truncate($table)
 | 
			
		||||
	{
 | 
			
		||||
		return 'DELETE FROM '.$table;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Delete statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates a platform-specific delete string from the supplied data
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _delete($table)
 | 
			
		||||
	{
 | 
			
		||||
		$this->qb_limit = FALSE;
 | 
			
		||||
		return parent::_delete($table);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * LIMIT
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates a platform-specific LIMIT clause
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$sql	SQL Query
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _limit($sql)
 | 
			
		||||
	{
 | 
			
		||||
		// Limit clause depends on if Interbase or Firebird
 | 
			
		||||
		if (stripos($this->version(), 'firebird') !== FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			$select = 'FIRST '.$this->qb_limit
 | 
			
		||||
				.($this->qb_offset ? ' SKIP '.$this->qb_offset : '');
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			$select = 'ROWS '
 | 
			
		||||
				.($this->qb_offset ? $this->qb_offset.' TO '.($this->qb_limit + $this->qb_offset) : $this->qb_limit);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return preg_replace('`SELECT`i', 'SELECT '.$select, $sql, 1);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Insert batch statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates a platform-specific insert string from the supplied data.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table	Table name
 | 
			
		||||
	 * @param	array	$keys	INSERT keys
 | 
			
		||||
	 * @param	array	$values	INSERT values
 | 
			
		||||
	 * @return	string|bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _insert_batch($table, $keys, $values)
 | 
			
		||||
	{
 | 
			
		||||
		return ($this->db_debug) ? $this->display_error('db_unsupported_feature') : FALSE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Close DB Connection
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _close()
 | 
			
		||||
	{
 | 
			
		||||
		ibase_close($this->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										252
									
								
								system/database/drivers/ibase/ibase_forge.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										252
									
								
								system/database/drivers/ibase/ibase_forge.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,252 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 3.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Interbase/Firebird Forge Class
 | 
			
		||||
 *
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_ibase_forge extends CI_DB_forge {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * CREATE TABLE IF statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_create_table_if	= FALSE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * RENAME TABLE statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_rename_table	= FALSE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * DROP TABLE IF statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_drop_table_if	= FALSE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * UNSIGNED support
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_unsigned		= array(
 | 
			
		||||
		'SMALLINT'	=> 'INTEGER',
 | 
			
		||||
		'INTEGER'	=> 'INT64',
 | 
			
		||||
		'FLOAT'		=> 'DOUBLE PRECISION'
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * NULL value representation in CREATE/ALTER TABLE statements
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_null		= 'NULL';
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Create database
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$db_name
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public function create_database($db_name)
 | 
			
		||||
	{
 | 
			
		||||
		// Firebird databases are flat files, so a path is required
 | 
			
		||||
 | 
			
		||||
		// Hostname is needed for remote access
 | 
			
		||||
		empty($this->db->hostname) OR $db_name = $this->hostname.':'.$db_name;
 | 
			
		||||
 | 
			
		||||
		return parent::create_database('"'.$db_name.'"');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Drop database
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$db_name	(ignored)
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public function drop_database($db_name)
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! ibase_drop_db($this->conn_id))
 | 
			
		||||
		{
 | 
			
		||||
			return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
 | 
			
		||||
		}
 | 
			
		||||
		elseif ( ! empty($this->db->data_cache['db_names']))
 | 
			
		||||
		{
 | 
			
		||||
			$key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE);
 | 
			
		||||
			if ($key !== FALSE)
 | 
			
		||||
			{
 | 
			
		||||
				unset($this->db->data_cache['db_names'][$key]);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return TRUE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * ALTER TABLE
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$alter_type	ALTER type
 | 
			
		||||
	 * @param	string	$table		Table name
 | 
			
		||||
	 * @param	mixed	$field		Column definition
 | 
			
		||||
	 * @return	string|string[]
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _alter_table($alter_type, $table, $field)
 | 
			
		||||
	{
 | 
			
		||||
		if (in_array($alter_type, array('DROP', 'ADD'), TRUE))
 | 
			
		||||
		{
 | 
			
		||||
			return parent::_alter_table($alter_type, $table, $field);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table);
 | 
			
		||||
		$sqls = array();
 | 
			
		||||
		for ($i = 0, $c = count($field); $i < $c; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			if ($field[$i]['_literal'] !== FALSE)
 | 
			
		||||
			{
 | 
			
		||||
				return FALSE;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (isset($field[$i]['type']))
 | 
			
		||||
			{
 | 
			
		||||
				$sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identififers($field[$i]['name'])
 | 
			
		||||
					.' TYPE '.$field[$i]['type'].$field[$i]['length'];
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if ( ! empty($field[$i]['default']))
 | 
			
		||||
			{
 | 
			
		||||
				$sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
 | 
			
		||||
					.' SET DEFAULT '.$field[$i]['default'];
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (isset($field[$i]['null']))
 | 
			
		||||
			{
 | 
			
		||||
				$sqls[] = 'UPDATE "RDB$RELATION_FIELDS" SET "RDB$NULL_FLAG" = '
 | 
			
		||||
					.($field[$i]['null'] === TRUE ? 'NULL' : '1')
 | 
			
		||||
					.' WHERE "RDB$FIELD_NAME" = '.$this->db->escape($field[$i]['name'])
 | 
			
		||||
					.' AND "RDB$RELATION_NAME" = '.$this->db->escape($table);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if ( ! empty($field[$i]['new_name']))
 | 
			
		||||
			{
 | 
			
		||||
				$sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
 | 
			
		||||
					.' TO '.$this->db->escape_identifiers($field[$i]['new_name']);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $sqls;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Process column
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	$field
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _process_column($field)
 | 
			
		||||
	{
 | 
			
		||||
		return $this->db->escape_identifiers($field['name'])
 | 
			
		||||
			.' '.$field['type'].$field['length']
 | 
			
		||||
			.$field['null']
 | 
			
		||||
			.$field['unique']
 | 
			
		||||
			.$field['default'];
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Field attribute TYPE
 | 
			
		||||
	 *
 | 
			
		||||
	 * Performs a data type mapping between different databases.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	&$attributes
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _attr_type(&$attributes)
 | 
			
		||||
	{
 | 
			
		||||
		switch (strtoupper($attributes['TYPE']))
 | 
			
		||||
		{
 | 
			
		||||
			case 'TINYINT':
 | 
			
		||||
				$attributes['TYPE'] = 'SMALLINT';
 | 
			
		||||
				$attributes['UNSIGNED'] = FALSE;
 | 
			
		||||
				return;
 | 
			
		||||
			case 'MEDIUMINT':
 | 
			
		||||
				$attributes['TYPE'] = 'INTEGER';
 | 
			
		||||
				$attributes['UNSIGNED'] = FALSE;
 | 
			
		||||
				return;
 | 
			
		||||
			case 'INT':
 | 
			
		||||
				$attributes['TYPE'] = 'INTEGER';
 | 
			
		||||
				return;
 | 
			
		||||
			case 'BIGINT':
 | 
			
		||||
				$attributes['TYPE'] = 'INT64';
 | 
			
		||||
				return;
 | 
			
		||||
			default: return;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Field attribute AUTO_INCREMENT
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	&$attributes
 | 
			
		||||
	 * @param	array	&$field
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _attr_auto_increment(&$attributes, &$field)
 | 
			
		||||
	{
 | 
			
		||||
		// Not supported
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										162
									
								
								system/database/drivers/ibase/ibase_result.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										162
									
								
								system/database/drivers/ibase/ibase_result.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,162 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 3.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Interbase/Firebird Result Class
 | 
			
		||||
 *
 | 
			
		||||
 * This class extends the parent result class: CI_DB_result
 | 
			
		||||
 *
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_ibase_result extends CI_DB_result {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Number of fields in the result set
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	public function num_fields()
 | 
			
		||||
	{
 | 
			
		||||
		return ibase_num_fields($this->result_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Fetch Field Names
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates an array of column names
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function list_fields()
 | 
			
		||||
	{
 | 
			
		||||
		$field_names = array();
 | 
			
		||||
		for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			$info = ibase_field_info($this->result_id, $i);
 | 
			
		||||
			$field_names[] = $info['name'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $field_names;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Field data
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates an array of objects containing field meta-data
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function field_data()
 | 
			
		||||
	{
 | 
			
		||||
		$retval = array();
 | 
			
		||||
		for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			$info = ibase_field_info($this->result_id, $i);
 | 
			
		||||
 | 
			
		||||
			$retval[$i]			= new stdClass();
 | 
			
		||||
			$retval[$i]->name		= $info['name'];
 | 
			
		||||
			$retval[$i]->type		= $info['type'];
 | 
			
		||||
			$retval[$i]->max_length		= $info['length'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $retval;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Free the result
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function free_result()
 | 
			
		||||
	{
 | 
			
		||||
		ibase_free_result($this->result_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Result - associative array
 | 
			
		||||
	 *
 | 
			
		||||
	 * Returns the result set as an array
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _fetch_assoc()
 | 
			
		||||
	{
 | 
			
		||||
		return ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Result - object
 | 
			
		||||
	 *
 | 
			
		||||
	 * Returns the result set as an object
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$class_name
 | 
			
		||||
	 * @return	object
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _fetch_object($class_name = 'stdClass')
 | 
			
		||||
	{
 | 
			
		||||
		$row = ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS);
 | 
			
		||||
 | 
			
		||||
		if ($class_name === 'stdClass' OR ! $row)
 | 
			
		||||
		{
 | 
			
		||||
			return $row;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$class_name = new $class_name();
 | 
			
		||||
		foreach ($row as $key => $value)
 | 
			
		||||
		{
 | 
			
		||||
			$class_name->$key = $value;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $class_name;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										70
									
								
								system/database/drivers/ibase/ibase_utility.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								system/database/drivers/ibase/ibase_utility.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,70 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 3.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Interbase/Firebird Utility Class
 | 
			
		||||
 *
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_ibase_utility extends CI_DB_utility {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Export
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$filename
 | 
			
		||||
	 * @return	mixed
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _backup($filename)
 | 
			
		||||
	{
 | 
			
		||||
		if ($service = ibase_service_attach($this->db->hostname, $this->db->username, $this->db->password))
 | 
			
		||||
		{
 | 
			
		||||
			$res = ibase_backup($service, $this->db->database, $filename.'.fbk');
 | 
			
		||||
 | 
			
		||||
			// Close the service connection
 | 
			
		||||
			ibase_service_detach($service);
 | 
			
		||||
			return $res;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return FALSE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								system/database/drivers/ibase/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								system/database/drivers/ibase/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
	<title>403 Forbidden</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<p>Directory access is forbidden.</p>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										11
									
								
								system/database/drivers/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								system/database/drivers/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
	<title>403 Forbidden</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<p>Directory access is forbidden.</p>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										11
									
								
								system/database/drivers/mssql/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								system/database/drivers/mssql/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
	<title>403 Forbidden</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<p>Directory access is forbidden.</p>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										519
									
								
								system/database/drivers/mssql/mssql_driver.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										519
									
								
								system/database/drivers/mssql/mssql_driver.php
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										152
									
								
								system/database/drivers/mssql/mssql_forge.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										152
									
								
								system/database/drivers/mssql/mssql_forge.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,152 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.3.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * MS SQL Forge Class
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Drivers
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_mssql_forge extends CI_DB_forge {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * CREATE TABLE IF statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_create_table_if	= "IF NOT EXISTS (SELECT * FROM sysobjects WHERE ID = object_id(N'%s') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)\nCREATE TABLE";
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * DROP TABLE IF statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_drop_table_if	= "IF EXISTS (SELECT * FROM sysobjects WHERE ID = object_id(N'%s') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)\nDROP TABLE";
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * UNSIGNED support
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_unsigned		= array(
 | 
			
		||||
		'TINYINT'	=> 'SMALLINT',
 | 
			
		||||
		'SMALLINT'	=> 'INT',
 | 
			
		||||
		'INT'		=> 'BIGINT',
 | 
			
		||||
		'REAL'		=> 'FLOAT'
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * ALTER TABLE
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$alter_type	ALTER type
 | 
			
		||||
	 * @param	string	$table		Table name
 | 
			
		||||
	 * @param	mixed	$field		Column definition
 | 
			
		||||
	 * @return	string|string[]
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _alter_table($alter_type, $table, $field)
 | 
			
		||||
	{
 | 
			
		||||
		if (in_array($alter_type, array('ADD', 'DROP'), TRUE))
 | 
			
		||||
		{
 | 
			
		||||
			return parent::_alter_table($alter_type, $table, $field);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table).' ALTER COLUMN ';
 | 
			
		||||
		$sqls = array();
 | 
			
		||||
		for ($i = 0, $c = count($field); $i < $c; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			$sqls[] = $sql.$this->_process_column($field[$i]);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $sqls;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Field attribute TYPE
 | 
			
		||||
	 *
 | 
			
		||||
	 * Performs a data type mapping between different databases.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	&$attributes
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _attr_type(&$attributes)
 | 
			
		||||
	{
 | 
			
		||||
		if (isset($attributes['CONSTRAINT']) && strpos($attributes['TYPE'], 'INT') !== FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			unset($attributes['CONSTRAINT']);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		switch (strtoupper($attributes['TYPE']))
 | 
			
		||||
		{
 | 
			
		||||
			case 'MEDIUMINT':
 | 
			
		||||
				$attributes['TYPE'] = 'INTEGER';
 | 
			
		||||
				$attributes['UNSIGNED'] = FALSE;
 | 
			
		||||
				return;
 | 
			
		||||
			case 'INTEGER':
 | 
			
		||||
				$attributes['TYPE'] = 'INT';
 | 
			
		||||
				return;
 | 
			
		||||
			default: return;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Field attribute AUTO_INCREMENT
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	&$attributes
 | 
			
		||||
	 * @param	array	&$field
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _attr_auto_increment(&$attributes, &$field)
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'int') !== FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			$field['auto_increment'] = ' IDENTITY(1,1)';
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										199
									
								
								system/database/drivers/mssql/mssql_result.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										199
									
								
								system/database/drivers/mssql/mssql_result.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,199 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.3.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * MSSQL Result Class
 | 
			
		||||
 *
 | 
			
		||||
 * This class extends the parent result class: CI_DB_result
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Drivers
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_mssql_result extends CI_DB_result {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Number of rows in the result set
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	public function num_rows()
 | 
			
		||||
	{
 | 
			
		||||
		return is_int($this->num_rows)
 | 
			
		||||
			? $this->num_rows
 | 
			
		||||
			: $this->num_rows = mssql_num_rows($this->result_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Number of fields in the result set
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	public function num_fields()
 | 
			
		||||
	{
 | 
			
		||||
		return mssql_num_fields($this->result_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Fetch Field Names
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates an array of column names
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function list_fields()
 | 
			
		||||
	{
 | 
			
		||||
		$field_names = array();
 | 
			
		||||
		mssql_field_seek($this->result_id, 0);
 | 
			
		||||
		while ($field = mssql_fetch_field($this->result_id))
 | 
			
		||||
		{
 | 
			
		||||
			$field_names[] = $field->name;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $field_names;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Field data
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates an array of objects containing field meta-data
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function field_data()
 | 
			
		||||
	{
 | 
			
		||||
		$retval = array();
 | 
			
		||||
		for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			$field = mssql_fetch_field($this->result_id, $i);
 | 
			
		||||
 | 
			
		||||
			$retval[$i]		= new stdClass();
 | 
			
		||||
			$retval[$i]->name	= $field->name;
 | 
			
		||||
			$retval[$i]->type	= $field->type;
 | 
			
		||||
			$retval[$i]->max_length	= $field->max_length;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $retval;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Free the result
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function free_result()
 | 
			
		||||
	{
 | 
			
		||||
		if (is_resource($this->result_id))
 | 
			
		||||
		{
 | 
			
		||||
			mssql_free_result($this->result_id);
 | 
			
		||||
			$this->result_id = FALSE;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Data Seek
 | 
			
		||||
	 *
 | 
			
		||||
	 * Moves the internal pointer to the desired offset. We call
 | 
			
		||||
	 * this internally before fetching results to make sure the
 | 
			
		||||
	 * result set starts at zero.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	int	$n
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public function data_seek($n = 0)
 | 
			
		||||
	{
 | 
			
		||||
		return mssql_data_seek($this->result_id, $n);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Result - associative array
 | 
			
		||||
	 *
 | 
			
		||||
	 * Returns the result set as an array
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _fetch_assoc()
 | 
			
		||||
	{
 | 
			
		||||
		return mssql_fetch_assoc($this->result_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Result - object
 | 
			
		||||
	 *
 | 
			
		||||
	 * Returns the result set as an object
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$class_name
 | 
			
		||||
	 * @return	object
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _fetch_object($class_name = 'stdClass')
 | 
			
		||||
	{
 | 
			
		||||
		$row = mssql_fetch_object($this->result_id);
 | 
			
		||||
 | 
			
		||||
		if ($class_name === 'stdClass' OR ! $row)
 | 
			
		||||
		{
 | 
			
		||||
			return $row;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$class_name = new $class_name();
 | 
			
		||||
		foreach ($row as $key => $value)
 | 
			
		||||
		{
 | 
			
		||||
			$class_name->$key = $value;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $class_name;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										78
									
								
								system/database/drivers/mssql/mssql_utility.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								system/database/drivers/mssql/mssql_utility.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.3.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * MS SQL Utility Class
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Drivers
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_mssql_utility extends CI_DB_utility {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List databases statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_list_databases	= 'EXEC sp_helpdb'; // Can also be: EXEC sp_databases
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * OPTIMIZE TABLE statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_optimize_table	= 'ALTER INDEX all ON %s REORGANIZE';
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Export
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	$params	Preferences
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _backup($params = array())
 | 
			
		||||
	{
 | 
			
		||||
		// Currently unsupported
 | 
			
		||||
		return $this->db->display_error('db_unsupported_feature');
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								system/database/drivers/mysql/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								system/database/drivers/mysql/index.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
	<title>403 Forbidden</title>
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<p>Directory access is forbidden.</p>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										495
									
								
								system/database/drivers/mysql/mysql_driver.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										495
									
								
								system/database/drivers/mysql/mysql_driver.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,495 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * MySQL Database Adapter Class
 | 
			
		||||
 *
 | 
			
		||||
 * Note: _DB is an extender class that the app controller
 | 
			
		||||
 * creates dynamically based on whether the query builder
 | 
			
		||||
 * class is being used or not.
 | 
			
		||||
 *
 | 
			
		||||
 * @package		CodeIgniter
 | 
			
		||||
 * @subpackage	Drivers
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_mysql_driver extends CI_DB {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Database driver
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	public $dbdriver = 'mysql';
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Compression flag
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public $compress = FALSE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * DELETE hack flag
 | 
			
		||||
	 *
 | 
			
		||||
	 * Whether to use the MySQL "delete hack" which allows the number
 | 
			
		||||
	 * of affected rows to be shown. Uses a preg_replace when enabled,
 | 
			
		||||
	 * adding a bit more processing to all queries.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public $delete_hack = TRUE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Strict ON flag
 | 
			
		||||
	 *
 | 
			
		||||
	 * Whether we're running in strict SQL mode.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public $stricton;
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Identifier escape character
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_escape_char = '`';
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Class constructor
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	$params
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function __construct($params)
 | 
			
		||||
	{
 | 
			
		||||
		parent::__construct($params);
 | 
			
		||||
 | 
			
		||||
		if ( ! empty($this->port))
 | 
			
		||||
		{
 | 
			
		||||
			$this->hostname .= ':'.$this->port;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Non-persistent database connection
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	bool	$persistent
 | 
			
		||||
	 * @return	resource
 | 
			
		||||
	 */
 | 
			
		||||
	public function db_connect($persistent = FALSE)
 | 
			
		||||
	{
 | 
			
		||||
		$client_flags = ($this->compress === FALSE) ? 0 : MYSQL_CLIENT_COMPRESS;
 | 
			
		||||
 | 
			
		||||
		if ($this->encrypt === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			$client_flags = $client_flags | MYSQL_CLIENT_SSL;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Error suppression is necessary mostly due to PHP 5.5+ issuing E_DEPRECATED messages
 | 
			
		||||
		$this->conn_id = ($persistent === TRUE)
 | 
			
		||||
			? mysql_pconnect($this->hostname, $this->username, $this->password, $client_flags)
 | 
			
		||||
			: mysql_connect($this->hostname, $this->username, $this->password, TRUE, $client_flags);
 | 
			
		||||
 | 
			
		||||
		// ----------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
		// Select the DB... assuming a database name is specified in the config file
 | 
			
		||||
		if ($this->database !== '' && ! $this->db_select())
 | 
			
		||||
		{
 | 
			
		||||
			log_message('error', 'Unable to select database: '.$this->database);
 | 
			
		||||
 | 
			
		||||
			return ($this->db_debug === TRUE)
 | 
			
		||||
				? $this->display_error('db_unable_to_select', $this->database)
 | 
			
		||||
				: FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (isset($this->stricton) && is_resource($this->conn_id))
 | 
			
		||||
		{
 | 
			
		||||
			if ($this->stricton)
 | 
			
		||||
			{
 | 
			
		||||
				$this->simple_query('SET SESSION sql_mode = CONCAT(@@sql_mode, ",", "STRICT_ALL_TABLES")');
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				$this->simple_query(
 | 
			
		||||
					'SET SESSION sql_mode =
 | 
			
		||||
					REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
 | 
			
		||||
					@@sql_mode,
 | 
			
		||||
					"STRICT_ALL_TABLES,", ""),
 | 
			
		||||
					",STRICT_ALL_TABLES", ""),
 | 
			
		||||
					"STRICT_ALL_TABLES", ""),
 | 
			
		||||
					"STRICT_TRANS_TABLES,", ""),
 | 
			
		||||
					",STRICT_TRANS_TABLES", ""),
 | 
			
		||||
					"STRICT_TRANS_TABLES", "")'
 | 
			
		||||
				);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $this->conn_id;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Reconnect
 | 
			
		||||
	 *
 | 
			
		||||
	 * Keep / reestablish the db connection if no queries have been
 | 
			
		||||
	 * sent for a length of time exceeding the server's idle timeout
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	public function reconnect()
 | 
			
		||||
	{
 | 
			
		||||
		if (mysql_ping($this->conn_id) === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			$this->conn_id = FALSE;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Select the database
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$database
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	public function db_select($database = '')
 | 
			
		||||
	{
 | 
			
		||||
		if ($database === '')
 | 
			
		||||
		{
 | 
			
		||||
			$database = $this->database;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (mysql_select_db($database, $this->conn_id))
 | 
			
		||||
		{
 | 
			
		||||
			$this->database = $database;
 | 
			
		||||
			$this->data_cache = array();
 | 
			
		||||
			return TRUE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return FALSE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Set client character set
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$charset
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _db_set_charset($charset)
 | 
			
		||||
	{
 | 
			
		||||
		return mysql_set_charset($charset, $this->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Database version number
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	public function version()
 | 
			
		||||
	{
 | 
			
		||||
		if (isset($this->data_cache['version']))
 | 
			
		||||
		{
 | 
			
		||||
			return $this->data_cache['version'];
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! $this->conn_id OR ($version = mysql_get_server_info($this->conn_id)) === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $this->data_cache['version'] = $version;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Execute the query
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$sql	an SQL query
 | 
			
		||||
	 * @return	mixed
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _execute($sql)
 | 
			
		||||
	{
 | 
			
		||||
		return mysql_query($this->_prep_query($sql), $this->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Prep the query
 | 
			
		||||
	 *
 | 
			
		||||
	 * If needed, each database adapter can prep the query string
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$sql	an SQL query
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _prep_query($sql)
 | 
			
		||||
	{
 | 
			
		||||
		// mysql_affected_rows() returns 0 for "DELETE FROM TABLE" queries. This hack
 | 
			
		||||
		// modifies the query so that it a proper number of affected rows is returned.
 | 
			
		||||
		if ($this->delete_hack === TRUE && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql))
 | 
			
		||||
		{
 | 
			
		||||
			return trim($sql).' WHERE 1=1';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $sql;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Begin Transaction
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _trans_begin()
 | 
			
		||||
	{
 | 
			
		||||
		$this->simple_query('SET AUTOCOMMIT=0');
 | 
			
		||||
		return $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Commit Transaction
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _trans_commit()
 | 
			
		||||
	{
 | 
			
		||||
		if ($this->simple_query('COMMIT'))
 | 
			
		||||
		{
 | 
			
		||||
			$this->simple_query('SET AUTOCOMMIT=1');
 | 
			
		||||
			return TRUE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return FALSE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Rollback Transaction
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _trans_rollback()
 | 
			
		||||
	{
 | 
			
		||||
		if ($this->simple_query('ROLLBACK'))
 | 
			
		||||
		{
 | 
			
		||||
			$this->simple_query('SET AUTOCOMMIT=1');
 | 
			
		||||
			return TRUE;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return FALSE;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Platform-dependent string escape
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _escape_str($str)
 | 
			
		||||
	{
 | 
			
		||||
		return mysql_real_escape_string($str, $this->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Affected Rows
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	public function affected_rows()
 | 
			
		||||
	{
 | 
			
		||||
		return mysql_affected_rows($this->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Insert ID
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	int
 | 
			
		||||
	 */
 | 
			
		||||
	public function insert_id()
 | 
			
		||||
	{
 | 
			
		||||
		return mysql_insert_id($this->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * List table query
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates a platform-specific query string so that the table names can be fetched
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	bool	$prefix_limit
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _list_tables($prefix_limit = FALSE)
 | 
			
		||||
	{
 | 
			
		||||
		$sql = 'SHOW TABLES FROM '.$this->_escape_char.$this->database.$this->_escape_char;
 | 
			
		||||
 | 
			
		||||
		if ($prefix_limit !== FALSE && $this->dbprefix !== '')
 | 
			
		||||
		{
 | 
			
		||||
			return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'";
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $sql;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Show column query
 | 
			
		||||
	 *
 | 
			
		||||
	 * Generates a platform-specific query string so that the column names can be fetched
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _list_columns($table = '')
 | 
			
		||||
	{
 | 
			
		||||
		return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Returns an object with field data
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function field_data($table)
 | 
			
		||||
	{
 | 
			
		||||
		if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
 | 
			
		||||
		{
 | 
			
		||||
			return FALSE;
 | 
			
		||||
		}
 | 
			
		||||
		$query = $query->result_object();
 | 
			
		||||
 | 
			
		||||
		$retval = array();
 | 
			
		||||
		for ($i = 0, $c = count($query); $i < $c; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			$retval[$i]			= new stdClass();
 | 
			
		||||
			$retval[$i]->name		= $query[$i]->Field;
 | 
			
		||||
 | 
			
		||||
			sscanf($query[$i]->Type, '%[a-z](%d)',
 | 
			
		||||
				$retval[$i]->type,
 | 
			
		||||
				$retval[$i]->max_length
 | 
			
		||||
			);
 | 
			
		||||
 | 
			
		||||
			$retval[$i]->default		= $query[$i]->Default;
 | 
			
		||||
			$retval[$i]->primary_key	= (int) ($query[$i]->Key === 'PRI');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $retval;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Error
 | 
			
		||||
	 *
 | 
			
		||||
	 * Returns an array containing code and message of the last
 | 
			
		||||
	 * database error that has occurred.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	array
 | 
			
		||||
	 */
 | 
			
		||||
	public function error()
 | 
			
		||||
	{
 | 
			
		||||
		return array('code' => mysql_errno($this->conn_id), 'message' => mysql_error($this->conn_id));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * FROM tables
 | 
			
		||||
	 *
 | 
			
		||||
	 * Groups tables in FROM clauses if needed, so there is no confusion
 | 
			
		||||
	 * about operator precedence.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _from_tables()
 | 
			
		||||
	{
 | 
			
		||||
		if ( ! empty($this->qb_join) && count($this->qb_from) > 1)
 | 
			
		||||
		{
 | 
			
		||||
			return '('.implode(', ', $this->qb_from).')';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return implode(', ', $this->qb_from);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Close DB Connection
 | 
			
		||||
	 *
 | 
			
		||||
	 * @return	void
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _close()
 | 
			
		||||
	{
 | 
			
		||||
		// Error suppression to avoid annoying E_WARNINGs in cases
 | 
			
		||||
		// where the connection has already been closed for some reason.
 | 
			
		||||
		@mysql_close($this->conn_id);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										243
									
								
								system/database/drivers/mysql/mysql_forge.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										243
									
								
								system/database/drivers/mysql/mysql_forge.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,243 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * CodeIgniter
 | 
			
		||||
 *
 | 
			
		||||
 * An open source application development framework for PHP
 | 
			
		||||
 *
 | 
			
		||||
 * This content is released under the MIT License (MIT)
 | 
			
		||||
 *
 | 
			
		||||
 * Copyright (c) 2019 - 2022, CodeIgniter Foundation
 | 
			
		||||
 *
 | 
			
		||||
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
			
		||||
 * of this software and associated documentation files (the "Software"), to deal
 | 
			
		||||
 * in the Software without restriction, including without limitation the rights
 | 
			
		||||
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
			
		||||
 * copies of the Software, and to permit persons to whom the Software is
 | 
			
		||||
 * furnished to do so, subject to the following conditions:
 | 
			
		||||
 *
 | 
			
		||||
 * The above copyright notice and this permission notice shall be included in
 | 
			
		||||
 * all copies or substantial portions of the Software.
 | 
			
		||||
 *
 | 
			
		||||
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
			
		||||
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
			
		||||
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
			
		||||
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
			
		||||
 * THE SOFTWARE.
 | 
			
		||||
 *
 | 
			
		||||
 * @package	CodeIgniter
 | 
			
		||||
 * @author	EllisLab Dev Team
 | 
			
		||||
 * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
 | 
			
		||||
 * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
 | 
			
		||||
 * @copyright	Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
 | 
			
		||||
 * @license	https://opensource.org/licenses/MIT	MIT License
 | 
			
		||||
 * @link	https://codeigniter.com
 | 
			
		||||
 * @since	Version 1.0.0
 | 
			
		||||
 * @filesource
 | 
			
		||||
 */
 | 
			
		||||
defined('BASEPATH') OR exit('No direct script access allowed');
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * MySQL Forge Class
 | 
			
		||||
 *
 | 
			
		||||
 * @category	Database
 | 
			
		||||
 * @author		EllisLab Dev Team
 | 
			
		||||
 * @link		https://codeigniter.com/userguide3/database/
 | 
			
		||||
 */
 | 
			
		||||
class CI_DB_mysql_forge extends CI_DB_forge {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * CREATE DATABASE statement
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_create_database	= 'CREATE DATABASE %s CHARACTER SET %s COLLATE %s';
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * CREATE TABLE keys flag
 | 
			
		||||
	 *
 | 
			
		||||
	 * Whether table keys are created from within the
 | 
			
		||||
	 * CREATE TABLE statement.
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	bool
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_create_table_keys	= TRUE;
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * UNSIGNED support
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	array
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_unsigned		= array(
 | 
			
		||||
		'TINYINT',
 | 
			
		||||
		'SMALLINT',
 | 
			
		||||
		'MEDIUMINT',
 | 
			
		||||
		'INT',
 | 
			
		||||
		'INTEGER',
 | 
			
		||||
		'BIGINT',
 | 
			
		||||
		'REAL',
 | 
			
		||||
		'DOUBLE',
 | 
			
		||||
		'DOUBLE PRECISION',
 | 
			
		||||
		'FLOAT',
 | 
			
		||||
		'DECIMAL',
 | 
			
		||||
		'NUMERIC'
 | 
			
		||||
	);
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * NULL value representation in CREATE/ALTER TABLE statements
 | 
			
		||||
	 *
 | 
			
		||||
	 * @var	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected $_null = 'NULL';
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * CREATE TABLE attributes
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	$attributes	Associative array of table attributes
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _create_table_attr($attributes)
 | 
			
		||||
	{
 | 
			
		||||
		$sql = '';
 | 
			
		||||
 | 
			
		||||
		foreach (array_keys($attributes) as $key)
 | 
			
		||||
		{
 | 
			
		||||
			if (is_string($key))
 | 
			
		||||
			{
 | 
			
		||||
				$sql .= ' '.strtoupper($key).' = '.$attributes[$key];
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! empty($this->db->char_set) && ! strpos($sql, 'CHARACTER SET') && ! strpos($sql, 'CHARSET'))
 | 
			
		||||
		{
 | 
			
		||||
			$sql .= ' DEFAULT CHARACTER SET = '.$this->db->char_set;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ( ! empty($this->db->dbcollat) && ! strpos($sql, 'COLLATE'))
 | 
			
		||||
		{
 | 
			
		||||
			$sql .= ' COLLATE = '.$this->db->dbcollat;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $sql;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * ALTER TABLE
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$alter_type	ALTER type
 | 
			
		||||
	 * @param	string	$table		Table name
 | 
			
		||||
	 * @param	mixed	$field		Column definition
 | 
			
		||||
	 * @return	string|string[]
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _alter_table($alter_type, $table, $field)
 | 
			
		||||
	{
 | 
			
		||||
		if ($alter_type === 'DROP')
 | 
			
		||||
		{
 | 
			
		||||
			return parent::_alter_table($alter_type, $table, $field);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table);
 | 
			
		||||
		for ($i = 0, $c = count($field); $i < $c; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			if ($field[$i]['_literal'] !== FALSE)
 | 
			
		||||
			{
 | 
			
		||||
				$field[$i] = ($alter_type === 'ADD')
 | 
			
		||||
						? "\n\tADD ".$field[$i]['_literal']
 | 
			
		||||
						: "\n\tMODIFY ".$field[$i]['_literal'];
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				if ($alter_type === 'ADD')
 | 
			
		||||
				{
 | 
			
		||||
					$field[$i]['_literal'] = "\n\tADD ";
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					$field[$i]['_literal'] = empty($field[$i]['new_name']) ? "\n\tMODIFY " : "\n\tCHANGE ";
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				$field[$i] = $field[$i]['_literal'].$this->_process_column($field[$i]);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return array($sql.implode(',', $field));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Process column
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	array	$field
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _process_column($field)
 | 
			
		||||
	{
 | 
			
		||||
		$extra_clause = isset($field['after'])
 | 
			
		||||
			? ' AFTER '.$this->db->escape_identifiers($field['after']) : '';
 | 
			
		||||
 | 
			
		||||
		if (empty($extra_clause) && isset($field['first']) && $field['first'] === TRUE)
 | 
			
		||||
		{
 | 
			
		||||
			$extra_clause = ' FIRST';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return $this->db->escape_identifiers($field['name'])
 | 
			
		||||
			.(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
 | 
			
		||||
			.' '.$field['type'].$field['length']
 | 
			
		||||
			.$field['unsigned']
 | 
			
		||||
			.$field['null']
 | 
			
		||||
			.$field['default']
 | 
			
		||||
			.$field['auto_increment']
 | 
			
		||||
			.$field['unique']
 | 
			
		||||
			.(empty($field['comment']) ? '' : ' COMMENT '.$field['comment'])
 | 
			
		||||
			.$extra_clause;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// --------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Process indexes
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param	string	$table	(ignored)
 | 
			
		||||
	 * @return	string
 | 
			
		||||
	 */
 | 
			
		||||
	protected function _process_indexes($table)
 | 
			
		||||
	{
 | 
			
		||||
		$sql = '';
 | 
			
		||||
 | 
			
		||||
		for ($i = 0, $c = count($this->keys); $i < $c; $i++)
 | 
			
		||||
		{
 | 
			
		||||
			if (is_array($this->keys[$i]))
 | 
			
		||||
			{
 | 
			
		||||
				for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++)
 | 
			
		||||
				{
 | 
			
		||||
					if ( ! isset($this->fields[$this->keys[$i][$i2]]))
 | 
			
		||||
					{
 | 
			
		||||
						unset($this->keys[$i][$i2]);
 | 
			
		||||
						continue;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			elseif ( ! isset($this->fields[$this->keys[$i]]))
 | 
			
		||||
			{
 | 
			
		||||
				unset($this->keys[$i]);
 | 
			
		||||
				continue;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			is_array($this->keys[$i]) OR $this->keys[$i] = array($this->keys[$i]);
 | 
			
		||||
 | 
			
		||||
			$sql .= ",\n\tKEY ".$this->db->escape_identifiers(implode('_', $this->keys[$i]))
 | 
			
		||||
				.' ('.implode(', ', $this->db->escape_identifiers($this->keys[$i])).')';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->keys = array();
 | 
			
		||||
 | 
			
		||||
		return $sql;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user