CodeIgniter 3.1.11 -> 3.4.5 (pocketarc fork) en PHP 8.3-fixes
- system/ vervangen door CodeIgniter 3.4.5 (pocketarc/codeigniter, PHP 8.2-8.5 compatibel) - config.php, mimes.php, user_agents.php en error-views bijgewerkt naar 3.4.5 - composer.json: php-constraint "^7.4 || ^8.0" zodat composer install op 8.3 werkt - PHP 8-fatals opgelost: count()/array-functies op FALSE/null, rekenen met lege strings, delen door nul, property zetten op FALSE, curly-brace string offsets, ongedefinieerde constanten, foute curl_setopt in Phantom_model::create_img - dynamic properties gedeclareerd in libraries, optionele parameters voor verplichte opgelost - vergelijkingen waar '' == 0 in PHP 8 anders uitvalt gecast naar (int) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -47,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/benchmark.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/benchmark.html
|
||||
*/
|
||||
class CI_Benchmark {
|
||||
|
||||
|
||||
+23
-73
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage CodeIgniter
|
||||
* @category Front-controller
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/
|
||||
* @link https://codeigniter.com/userguide3/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -55,7 +56,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @var string
|
||||
*
|
||||
*/
|
||||
const CI_VERSION = '3.1.11';
|
||||
const CI_VERSION = '3.4.5';
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
@@ -79,57 +80,6 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*/
|
||||
require_once(BASEPATH.'core/Common.php');
|
||||
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Security procedures
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
|
||||
if ( ! is_php('5.4'))
|
||||
{
|
||||
ini_set('magic_quotes_runtime', 0);
|
||||
|
||||
if ((bool) ini_get('register_globals'))
|
||||
{
|
||||
$_protected = array(
|
||||
'_SERVER',
|
||||
'_GET',
|
||||
'_POST',
|
||||
'_FILES',
|
||||
'_REQUEST',
|
||||
'_SESSION',
|
||||
'_ENV',
|
||||
'_COOKIE',
|
||||
'GLOBALS',
|
||||
'HTTP_RAW_POST_DATA',
|
||||
'system_path',
|
||||
'application_folder',
|
||||
'view_folder',
|
||||
'_protected',
|
||||
'_registered'
|
||||
);
|
||||
|
||||
$_registered = ini_get('variables_order');
|
||||
foreach (array('E' => '_ENV', 'G' => '_GET', 'P' => '_POST', 'C' => '_COOKIE', 'S' => '_SERVER') as $key => $superglobal)
|
||||
{
|
||||
if (strpos($_registered, $key) === FALSE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (array_keys($$superglobal) as $var)
|
||||
{
|
||||
if (isset($GLOBALS[$var]) && ! in_array($var, $_protected, TRUE))
|
||||
{
|
||||
$GLOBALS[$var] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Define a custom error handler so we can log PHP errors
|
||||
@@ -192,20 +142,6 @@ if ( ! is_php('5.4'))
|
||||
$BM->mark('total_execution_time_start');
|
||||
$BM->mark('loading_time:_base_classes_start');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the hooks class
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT =& load_class('Hooks', 'core');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a "pre_system" hook?
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT->call_hook('pre_system');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the config class
|
||||
@@ -227,6 +163,20 @@ if ( ! is_php('5.4'))
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the hooks class
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT =& load_class('Hooks', 'core', $CFG);
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Is there a "pre_system" hook?
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$EXT->call_hook('pre_system');
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Important charset-related stuff
|
||||
@@ -294,14 +244,14 @@ if ( ! is_php('5.4'))
|
||||
* Instantiate the UTF-8 class
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$UNI =& load_class('Utf8', 'core');
|
||||
$UNI =& load_class('Utf8', 'core', $charset);
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the URI class
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$URI =& load_class('URI', 'core');
|
||||
$URI =& load_class('URI', 'core', $CFG);
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
@@ -332,14 +282,14 @@ if ( ! is_php('5.4'))
|
||||
* Load the security class for xss and csrf support
|
||||
* -----------------------------------------------------
|
||||
*/
|
||||
$SEC =& load_class('Security', 'core');
|
||||
$SEC =& load_class('Security', 'core', $charset);
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Load the Input class and sanitize globals
|
||||
* ------------------------------------------------------
|
||||
*/
|
||||
$IN =& load_class('Input', 'core');
|
||||
$IN =& load_class('Input', 'core', $SEC);
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
@@ -434,7 +384,7 @@ if ( ! is_php('5.4'))
|
||||
* ReflectionMethod::isConstructor() is the ONLY reliable check,
|
||||
* knowing which method will be executed as a constructor.
|
||||
*/
|
||||
elseif ( ! is_callable(array($class, $method)))
|
||||
else
|
||||
{
|
||||
$reflection = new ReflectionMethod($class, $method);
|
||||
if ( ! $reflection->isPublic() OR $reflection->isConstructor())
|
||||
|
||||
+16
-12
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage CodeIgniter
|
||||
* @category Common Functions
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/
|
||||
* @link https://codeigniter.com/userguide3/
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -81,8 +82,7 @@ if ( ! function_exists('is_really_writable'))
|
||||
* Tests for file writability
|
||||
*
|
||||
* is_writable() returns TRUE on Windows servers when you really can't write to
|
||||
* the file, based on the read-only attribute. is_writable() is also unreliable
|
||||
* on Unix servers if safe_mode is on.
|
||||
* the file, based on the read-only attribute.
|
||||
*
|
||||
* @link https://bugs.php.net/bug.php?id=54709
|
||||
* @param string
|
||||
@@ -90,8 +90,8 @@ if ( ! function_exists('is_really_writable'))
|
||||
*/
|
||||
function is_really_writable($file)
|
||||
{
|
||||
// If we're on a Unix server with safe_mode off we call is_writable
|
||||
if (DIRECTORY_SEPARATOR === '/' && (is_php('5.4') OR ! ini_get('safe_mode')))
|
||||
// If we're on a UNIX-like server, just is_writable()
|
||||
if (DIRECTORY_SEPARATOR === '/')
|
||||
{
|
||||
return is_writable($file);
|
||||
}
|
||||
@@ -499,6 +499,7 @@ if ( ! function_exists('set_status_header'))
|
||||
$stati = array(
|
||||
100 => 'Continue',
|
||||
101 => 'Switching Protocols',
|
||||
103 => 'Early Hints',
|
||||
|
||||
200 => 'OK',
|
||||
201 => 'Created',
|
||||
@@ -507,6 +508,7 @@ if ( ! function_exists('set_status_header'))
|
||||
204 => 'No Content',
|
||||
205 => 'Reset Content',
|
||||
206 => 'Partial Content',
|
||||
207 => 'Multi-Status',
|
||||
|
||||
300 => 'Multiple Choices',
|
||||
301 => 'Moved Permanently',
|
||||
@@ -515,6 +517,7 @@ if ( ! function_exists('set_status_header'))
|
||||
304 => 'Not Modified',
|
||||
305 => 'Use Proxy',
|
||||
307 => 'Temporary Redirect',
|
||||
308 => 'Permanent Redirect',
|
||||
|
||||
400 => 'Bad Request',
|
||||
401 => 'Unauthorized',
|
||||
@@ -534,11 +537,13 @@ if ( ! function_exists('set_status_header'))
|
||||
415 => 'Unsupported Media Type',
|
||||
416 => 'Requested Range Not Satisfiable',
|
||||
417 => 'Expectation Failed',
|
||||
421 => 'Misdirected Request',
|
||||
422 => 'Unprocessable Entity',
|
||||
426 => 'Upgrade Required',
|
||||
428 => 'Precondition Required',
|
||||
429 => 'Too Many Requests',
|
||||
431 => 'Request Header Fields Too Large',
|
||||
451 => 'Unavailable For Legal Reasons',
|
||||
|
||||
500 => 'Internal Server Error',
|
||||
501 => 'Not Implemented',
|
||||
@@ -565,7 +570,7 @@ if ( ! function_exists('set_status_header'))
|
||||
return;
|
||||
}
|
||||
|
||||
$server_protocol = (isset($_SERVER['SERVER_PROTOCOL']) && in_array($_SERVER['SERVER_PROTOCOL'], array('HTTP/1.0', 'HTTP/1.1', 'HTTP/2'), TRUE))
|
||||
$server_protocol = (isset($_SERVER['SERVER_PROTOCOL']) && in_array($_SERVER['SERVER_PROTOCOL'], array('HTTP/1.0', 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0'), TRUE))
|
||||
? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
|
||||
header($server_protocol.' '.$code.' '.$text, TRUE, $code);
|
||||
}
|
||||
@@ -625,7 +630,7 @@ if ( ! function_exists('_error_handler'))
|
||||
|
||||
// If the error is fatal, the execution of the script should be stopped because
|
||||
// errors can't be recovered from. Halting the script conforms with PHP's
|
||||
// default error handling. See http://www.php.net/manual/en/errorfunc.constants.php
|
||||
// default error handling. See https://secure.php.net/manual/en/errorfunc.constants.php
|
||||
if ($is_error)
|
||||
{
|
||||
exit(1); // EXIT_ERROR
|
||||
@@ -722,7 +727,7 @@ if ( ! function_exists('remove_invisible_characters'))
|
||||
|
||||
do
|
||||
{
|
||||
$str = preg_replace($non_displayables, '', $str, -1, $count);
|
||||
$str = preg_replace($non_displayables, '', (string)$str, -1, $count);
|
||||
}
|
||||
while ($count);
|
||||
|
||||
@@ -778,11 +783,9 @@ if ( ! function_exists('_stringify_attributes'))
|
||||
*/
|
||||
function _stringify_attributes($attributes, $js = FALSE)
|
||||
{
|
||||
$atts = NULL;
|
||||
|
||||
if (empty($attributes))
|
||||
{
|
||||
return $atts;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (is_string($attributes))
|
||||
@@ -792,6 +795,7 @@ if ( ! function_exists('_stringify_attributes'))
|
||||
|
||||
$attributes = (array) $attributes;
|
||||
|
||||
$atts = '';
|
||||
foreach ($attributes as $key => $val)
|
||||
{
|
||||
$atts .= ($js) ? $key.'='.$val.',' : ' '.$key.'="'.$val.'"';
|
||||
|
||||
+18
-17
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/config.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/config.html
|
||||
*/
|
||||
class CI_Config {
|
||||
|
||||
@@ -169,7 +170,7 @@ class CI_Config {
|
||||
$this->is_loaded[] = $file_path;
|
||||
$config = NULL;
|
||||
$loaded = TRUE;
|
||||
log_message('debug', 'Config file loaded: '.$file_path);
|
||||
log_message('info', 'Config file loaded: '.$file_path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,6 +325,20 @@ class CI_Config {
|
||||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* System URL
|
||||
*
|
||||
* @deprecated 3.0.0
|
||||
* @return string
|
||||
*/
|
||||
public function system_url()
|
||||
{
|
||||
$x = explode('/', preg_replace('|/*(.+?)/*$|', '\\1', BASEPATH));
|
||||
return $this->slash_item('base_url').end($x).'/';
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Build URI string
|
||||
*
|
||||
@@ -350,20 +365,6 @@ class CI_Config {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -47,8 +48,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/general/controllers.html
|
||||
* @link https://codeigniter.com/userguide3/general/controllers.html
|
||||
*/
|
||||
#[AllowDynamicProperties]
|
||||
class CI_Controller {
|
||||
|
||||
/**
|
||||
|
||||
+34
-14
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Exceptions
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/exceptions.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/exceptions.html
|
||||
*/
|
||||
class CI_Exceptions {
|
||||
|
||||
@@ -61,18 +62,25 @@ class CI_Exceptions {
|
||||
* @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'
|
||||
E_ERROR => 'Error',
|
||||
E_RECOVERABLE_ERROR => 'Recoverable Error',
|
||||
E_WARNING => 'Warning',
|
||||
E_PARSE => 'Parsing Error',
|
||||
E_NOTICE => 'Notice',
|
||||
E_DEPRECATED => 'Deprecated 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_USER_DEPRECATED => 'User Deprecated Notice',
|
||||
|
||||
# 2048 is E_STRICT, but it's deprecated in PHP 8.4.
|
||||
# We're keeping this here for backwards compatibility.
|
||||
# If we're on older PHP, E_STRICT errors will be labelled correctly, and if we're on PHP 8.4+, this will be ignored.
|
||||
2048 => 'Strict Notice',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -161,6 +169,10 @@ class CI_Exceptions {
|
||||
{
|
||||
$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
$templates_path = rtrim($templates_path, '/\\').DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
if (is_cli())
|
||||
{
|
||||
@@ -194,6 +206,10 @@ class CI_Exceptions {
|
||||
{
|
||||
$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
$templates_path = rtrim($templates_path, '/\\').DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
$message = $exception->getMessage();
|
||||
if (empty($message))
|
||||
@@ -240,6 +256,10 @@ class CI_Exceptions {
|
||||
{
|
||||
$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
$templates_path = rtrim($templates_path, '/\\').DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/general/hooks.html
|
||||
* @link https://codeigniter.com/userguide3/general/hooks.html
|
||||
*/
|
||||
class CI_Hooks {
|
||||
|
||||
@@ -83,16 +84,16 @@ class CI_Hooks {
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param CI_Config $config
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(CI_Config $config)
|
||||
{
|
||||
$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)
|
||||
if ($config->item('enable_hooks') === FALSE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
+74
-249
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Input
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/input.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/input.html
|
||||
*/
|
||||
class CI_Input {
|
||||
|
||||
@@ -57,45 +58,6 @@ class CI_Input {
|
||||
*/
|
||||
protected $ip_address = FALSE;
|
||||
|
||||
/**
|
||||
* Allow GET array flag
|
||||
*
|
||||
* If set to FALSE, then $_GET will be set to an empty array.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_allow_get_array = TRUE;
|
||||
|
||||
/**
|
||||
* Standardize new lines flag
|
||||
*
|
||||
* If set to TRUE, then newlines are standardized.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_standardize_newlines;
|
||||
|
||||
/**
|
||||
* Enable XSS flag
|
||||
*
|
||||
* Determines whether the XSS filter is always active when
|
||||
* GET, POST or COOKIE data is encountered.
|
||||
* Set automatically based on config setting.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_enable_xss = FALSE;
|
||||
|
||||
/**
|
||||
* Enable CSRF flag
|
||||
*
|
||||
* Enables a CSRF cookie token to be set.
|
||||
* Set automatically based on config setting.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_enable_csrf = FALSE;
|
||||
|
||||
/**
|
||||
* List of all HTTP request headers
|
||||
*
|
||||
@@ -122,8 +84,15 @@ class CI_Input {
|
||||
*/
|
||||
protected $_input_stream;
|
||||
|
||||
/**
|
||||
* CI_Security instance
|
||||
*
|
||||
* Used for the optional $xss_filter parameter that most
|
||||
* getter methods have here.
|
||||
*
|
||||
* @var CI_Security
|
||||
*/
|
||||
protected $security;
|
||||
protected $uni;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -135,30 +104,9 @@ class CI_Input {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(CI_Security &$security)
|
||||
{
|
||||
$this->_allow_get_array = (config_item('allow_get_array') !== FALSE);
|
||||
$this->_enable_xss = (config_item('global_xss_filtering') === TRUE);
|
||||
$this->_enable_csrf = (config_item('csrf_protection') === TRUE);
|
||||
$this->_standardize_newlines = (bool) config_item('standardize_newlines');
|
||||
|
||||
$this->security =& load_class('Security', 'core');
|
||||
|
||||
// Do we need the UTF-8 class?
|
||||
if (UTF8_ENABLED === TRUE)
|
||||
{
|
||||
$this->uni =& load_class('Utf8', 'core');
|
||||
}
|
||||
|
||||
// Sanitize global arrays
|
||||
$this->_sanitize_globals();
|
||||
|
||||
// CSRF Protection check
|
||||
if ($this->_enable_csrf === TRUE && ! is_cli())
|
||||
{
|
||||
$this->security->csrf_verify();
|
||||
}
|
||||
|
||||
$this->security = $security;
|
||||
log_message('info', 'Input Class Initialized');
|
||||
}
|
||||
|
||||
@@ -174,10 +122,8 @@ class CI_Input {
|
||||
* @param bool $xss_clean Whether to apply XSS filtering
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _fetch_from_array(&$array, $index = NULL, $xss_clean = NULL)
|
||||
protected function _fetch_from_array(&$array, $index = NULL, $xss_clean = FALSE)
|
||||
{
|
||||
is_bool($xss_clean) OR $xss_clean = $this->_enable_xss;
|
||||
|
||||
// If $index is NULL, it means that the whole $array is requested
|
||||
isset($index) OR $index = array_keys($array);
|
||||
|
||||
@@ -237,7 +183,7 @@ class CI_Input {
|
||||
* @param bool $xss_clean Whether to apply XSS filtering
|
||||
* @return mixed
|
||||
*/
|
||||
public function get($index = NULL, $xss_clean = NULL)
|
||||
public function get($index = NULL, $xss_clean = FALSE)
|
||||
{
|
||||
return $this->_fetch_from_array($_GET, $index, $xss_clean);
|
||||
}
|
||||
@@ -251,7 +197,7 @@ class CI_Input {
|
||||
* @param bool $xss_clean Whether to apply XSS filtering
|
||||
* @return mixed
|
||||
*/
|
||||
public function post($index = NULL, $xss_clean = NULL)
|
||||
public function post($index = NULL, $xss_clean = FALSE)
|
||||
{
|
||||
return $this->_fetch_from_array($_POST, $index, $xss_clean);
|
||||
}
|
||||
@@ -265,11 +211,10 @@ class CI_Input {
|
||||
* @param bool $xss_clean Whether to apply XSS filtering
|
||||
* @return mixed
|
||||
*/
|
||||
public function post_get($index, $xss_clean = NULL)
|
||||
public function post_get($index, $xss_clean = FALSE)
|
||||
{
|
||||
return isset($_POST[$index])
|
||||
? $this->post($index, $xss_clean)
|
||||
: $this->get($index, $xss_clean);
|
||||
$output = $this->post($index, $xss_clean);
|
||||
return isset($output) ? $output : $this->get($index, $xss_clean);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -281,11 +226,10 @@ class CI_Input {
|
||||
* @param bool $xss_clean Whether to apply XSS filtering
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_post($index, $xss_clean = NULL)
|
||||
public function get_post($index, $xss_clean = FALSE)
|
||||
{
|
||||
return isset($_GET[$index])
|
||||
? $this->get($index, $xss_clean)
|
||||
: $this->post($index, $xss_clean);
|
||||
$output = $this->get($index, $xss_clean);
|
||||
return isset($output) ? $output : $this->post($index, $xss_clean);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -297,7 +241,7 @@ class CI_Input {
|
||||
* @param bool $xss_clean Whether to apply XSS filtering
|
||||
* @return mixed
|
||||
*/
|
||||
public function cookie($index = NULL, $xss_clean = NULL)
|
||||
public function cookie($index = NULL, $xss_clean = FALSE)
|
||||
{
|
||||
return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
|
||||
}
|
||||
@@ -311,7 +255,7 @@ class CI_Input {
|
||||
* @param bool $xss_clean Whether to apply XSS filtering
|
||||
* @return mixed
|
||||
*/
|
||||
public function server($index, $xss_clean = NULL)
|
||||
public function server($index, $xss_clean = FALSE)
|
||||
{
|
||||
return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
|
||||
}
|
||||
@@ -327,7 +271,7 @@ class CI_Input {
|
||||
* @param bool $xss_clean Whether to apply XSS filtering
|
||||
* @return mixed
|
||||
*/
|
||||
public function input_stream($index = NULL, $xss_clean = NULL)
|
||||
public function input_stream($index = NULL, $xss_clean = FALSE)
|
||||
{
|
||||
// Prior to PHP 5.6, the input stream can only be read once,
|
||||
// so we'll need to check if we have already done that first.
|
||||
@@ -357,14 +301,15 @@ class CI_Input {
|
||||
* @param string $prefix Cookie name prefix
|
||||
* @param bool $secure Whether to only transfer cookies via SSL
|
||||
* @param bool $httponly Whether to only makes the cookie accessible via HTTP (no javascript)
|
||||
* @param string $samesite SameSite attribute
|
||||
* @return void
|
||||
*/
|
||||
public function set_cookie($name, $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = NULL, $httponly = NULL)
|
||||
public function set_cookie($name, $value = '', $expire = 0, $domain = '', $path = '/', $prefix = '', $secure = NULL, $httponly = NULL, $samesite = NULL)
|
||||
{
|
||||
if (is_array($name))
|
||||
{
|
||||
// always leave 'name' in last place, as the loop will break otherwise, due to $$item
|
||||
foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name') as $item)
|
||||
foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'samesite', 'name') as $item)
|
||||
{
|
||||
if (isset($name[$item]))
|
||||
{
|
||||
@@ -396,16 +341,56 @@ class CI_Input {
|
||||
? (bool) config_item('cookie_httponly')
|
||||
: (bool) $httponly;
|
||||
|
||||
if ( ! is_numeric($expire))
|
||||
if ( ! is_numeric($expire) OR $expire < 0)
|
||||
{
|
||||
$expire = time() - 86500;
|
||||
$expire = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$expire = ($expire > 0) ? time() + $expire : 0;
|
||||
}
|
||||
|
||||
setcookie($prefix.$name, $value, $expire, $path, $domain, $secure, $httponly);
|
||||
isset($samesite) OR $samesite = config_item('cookie_samesite');
|
||||
if (isset($samesite))
|
||||
{
|
||||
$samesite = ucfirst(strtolower($samesite));
|
||||
in_array($samesite, array('Lax', 'Strict', 'None'), TRUE) OR $samesite = 'Lax';
|
||||
}
|
||||
else
|
||||
{
|
||||
$samesite = 'Lax';
|
||||
}
|
||||
|
||||
if ($samesite === 'None' && ! $secure)
|
||||
{
|
||||
log_message('error', $name.' cookie sent with SameSite=None, but without Secure attribute.');
|
||||
}
|
||||
|
||||
if ( ! is_php('7.3'))
|
||||
{
|
||||
$maxage = $expire - time();
|
||||
if ($maxage < 1)
|
||||
{
|
||||
$maxage = 0;
|
||||
}
|
||||
|
||||
$cookie_header = 'Set-Cookie: '.$prefix.$name.'='.rawurlencode($value);
|
||||
$cookie_header .= ($expire === 0 ? '' : '; Expires='.gmdate('D, d-M-Y H:i:s T', $expire)).'; Max-Age='.$maxage;
|
||||
$cookie_header .= '; Path='.$path.($domain !== '' ? '; Domain='.$domain : '');
|
||||
$cookie_header .= ($secure ? '; Secure' : '').($httponly ? '; HttpOnly' : '').'; SameSite='.$samesite;
|
||||
header($cookie_header);
|
||||
return;
|
||||
}
|
||||
|
||||
$setcookie_options = array(
|
||||
'expires' => $expire,
|
||||
'path' => $path,
|
||||
'domain' => $domain,
|
||||
'secure' => $secure,
|
||||
'httponly' => $httponly,
|
||||
'samesite' => $samesite,
|
||||
);
|
||||
setcookie($prefix.$name, $value, $setcookie_options);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -565,7 +550,7 @@ class CI_Input {
|
||||
$which = FILTER_FLAG_IPV6;
|
||||
break;
|
||||
default:
|
||||
$which = NULL;
|
||||
$which = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -579,174 +564,13 @@ class CI_Input {
|
||||
*
|
||||
* @return string|null User Agent string or NULL if it doesn't exist
|
||||
*/
|
||||
public function user_agent($xss_clean = NULL)
|
||||
public function user_agent($xss_clean = FALSE)
|
||||
{
|
||||
return $this->_fetch_from_array($_SERVER, 'HTTP_USER_AGENT', $xss_clean);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Sanitize Globals
|
||||
*
|
||||
* Internal method serving for the following purposes:
|
||||
*
|
||||
* - Unsets $_GET data, if query strings are not enabled
|
||||
* - Cleans POST, COOKIE and SERVER data
|
||||
* - Standardizes newline characters to PHP_EOL
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _sanitize_globals()
|
||||
{
|
||||
// Is $_GET data allowed? If not we'll set the $_GET to an empty array
|
||||
if ($this->_allow_get_array === FALSE)
|
||||
{
|
||||
$_GET = array();
|
||||
}
|
||||
elseif (is_array($_GET))
|
||||
{
|
||||
foreach ($_GET as $key => $val)
|
||||
{
|
||||
$_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
|
||||
}
|
||||
}
|
||||
|
||||
// Clean $_POST Data
|
||||
if (is_array($_POST))
|
||||
{
|
||||
foreach ($_POST as $key => $val)
|
||||
{
|
||||
$_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
|
||||
}
|
||||
}
|
||||
|
||||
// Clean $_COOKIE Data
|
||||
if (is_array($_COOKIE))
|
||||
{
|
||||
// Also get rid of specially treated cookies that might be set by a server
|
||||
// or silly application, that are of no use to a CI application anyway
|
||||
// but that when present will trip our 'Disallowed Key Characters' alarm
|
||||
// http://www.ietf.org/rfc/rfc2109.txt
|
||||
// note that the key names below are single quoted strings, and are not PHP variables
|
||||
unset(
|
||||
$_COOKIE['$Version'],
|
||||
$_COOKIE['$Path'],
|
||||
$_COOKIE['$Domain']
|
||||
);
|
||||
|
||||
foreach ($_COOKIE as $key => $val)
|
||||
{
|
||||
if (($cookie_key = $this->_clean_input_keys($key)) !== FALSE)
|
||||
{
|
||||
$_COOKIE[$cookie_key] = $this->_clean_input_data($val);
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($_COOKIE[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sanitize PHP_SELF
|
||||
$_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
|
||||
|
||||
log_message('debug', 'Global POST, GET and COOKIE data sanitized');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Clean Input Data
|
||||
*
|
||||
* Internal method that aids in escaping data and
|
||||
* standardizing newline characters to PHP_EOL.
|
||||
*
|
||||
* @param string|string[] $str Input string(s)
|
||||
* @return string
|
||||
*/
|
||||
protected function _clean_input_data($str)
|
||||
{
|
||||
if (is_array($str))
|
||||
{
|
||||
$new_array = array();
|
||||
foreach (array_keys($str) as $key)
|
||||
{
|
||||
$new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($str[$key]);
|
||||
}
|
||||
return $new_array;
|
||||
}
|
||||
|
||||
/* We strip slashes if magic quotes is on to keep things consistent
|
||||
|
||||
NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
|
||||
it will probably not exist in future versions at all.
|
||||
*/
|
||||
if ( ! is_php('5.4') && get_magic_quotes_gpc())
|
||||
{
|
||||
$str = stripslashes($str);
|
||||
}
|
||||
|
||||
// Clean UTF-8 if supported
|
||||
if (UTF8_ENABLED === TRUE)
|
||||
{
|
||||
$str = $this->uni->clean_string($str);
|
||||
}
|
||||
|
||||
// Remove control characters
|
||||
$str = remove_invisible_characters($str, FALSE);
|
||||
|
||||
// Standardize newlines if needed
|
||||
if ($this->_standardize_newlines === TRUE)
|
||||
{
|
||||
return preg_replace('/(?:\r\n|[\r\n])/', PHP_EOL, $str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Clean Keys
|
||||
*
|
||||
* Internal method that helps to prevent malicious users
|
||||
* from trying to exploit keys we make sure that keys are
|
||||
* only named with alpha-numeric text and a few other items.
|
||||
*
|
||||
* @param string $str Input string
|
||||
* @param bool $fatal Whether to terminate script exection
|
||||
* or to return FALSE if an invalid
|
||||
* key is encountered
|
||||
* @return string|bool
|
||||
*/
|
||||
protected function _clean_input_keys($str, $fatal = TRUE)
|
||||
{
|
||||
if ( ! preg_match('/^[a-z0-9:_\/|-]+$/i', $str))
|
||||
{
|
||||
if ($fatal === TRUE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
set_status_header(503);
|
||||
echo 'Disallowed Key Characters.';
|
||||
exit(7); // EXIT_USER_INPUT
|
||||
}
|
||||
}
|
||||
|
||||
// Clean UTF-8 if supported
|
||||
if (UTF8_ENABLED === TRUE)
|
||||
{
|
||||
return $this->uni->clean_string($str);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Request Headers
|
||||
*
|
||||
@@ -844,6 +668,7 @@ class CI_Input {
|
||||
* Test to see if a request was made from the command line.
|
||||
*
|
||||
* @deprecated 3.0.0 Use is_cli() instead
|
||||
* @see is_cli()
|
||||
* @return bool
|
||||
*/
|
||||
public function is_cli_request()
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Language
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/language.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/language.html
|
||||
*/
|
||||
class CI_Lang {
|
||||
|
||||
@@ -189,7 +190,7 @@ class CI_Lang {
|
||||
*/
|
||||
public function line($line, $log_errors = TRUE)
|
||||
{
|
||||
$value = isset($this->language[$line]) ? $this->language[$line] : FALSE;
|
||||
$value = ($line !== NULL && isset($this->language[$line])) ? $this->language[$line] : FALSE;
|
||||
|
||||
// Because killer robots like unicorns!
|
||||
if ($value === FALSE && $log_errors === TRUE)
|
||||
|
||||
+63
-30
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,8 +47,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Loader
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/loader.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/loader.html
|
||||
*/
|
||||
#[AllowDynamicProperties]
|
||||
class CI_Loader {
|
||||
|
||||
// All these are set automatically. Don't mess with them.
|
||||
@@ -93,6 +95,13 @@ class CI_Loader {
|
||||
*/
|
||||
protected $_ci_cached_vars = array();
|
||||
|
||||
/**
|
||||
* Stack of variable arrays to provide nested _ci_load calls with all variables from parent calls
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_ci_load_vars_stack = array();
|
||||
|
||||
/**
|
||||
* List of loaded classes
|
||||
*
|
||||
@@ -348,9 +357,10 @@ class CI_Loader {
|
||||
throw new RuntimeException('Unable to locate the model you have specified: '.$model);
|
||||
}
|
||||
}
|
||||
elseif ( ! is_subclass_of($model, 'CI_Model'))
|
||||
|
||||
if ( ! is_subclass_of($model, 'CI_Model'))
|
||||
{
|
||||
throw new RuntimeException("Class ".$model." already exists and doesn't extend CI_Model");
|
||||
throw new RuntimeException("Class ".$model." doesn't extend CI_Model");
|
||||
}
|
||||
|
||||
$this->_ci_models[] = $name;
|
||||
@@ -367,19 +377,16 @@ class CI_Loader {
|
||||
*
|
||||
* @param mixed $params Database configuration options
|
||||
* @param bool $return Whether to return the database object
|
||||
* @param bool $query_builder Whether to enable Query Builder
|
||||
* (overrides the configuration setting)
|
||||
*
|
||||
* @return object|bool Database object if $return is set to TRUE,
|
||||
* FALSE on failure, CI_Loader instance in any other case
|
||||
*/
|
||||
public function database($params = '', $return = FALSE, $query_builder = NULL)
|
||||
public function database($params = '', $return = FALSE)
|
||||
{
|
||||
// Grab the super object
|
||||
$CI =& get_instance();
|
||||
|
||||
// Do we even need to load the database class?
|
||||
if ($return === FALSE && $query_builder === NULL && isset($CI->db) && is_object($CI->db) && ! empty($CI->db->conn_id))
|
||||
if ($return === FALSE && isset($CI->db) && is_object($CI->db) && ! empty($CI->db->conn_id))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -388,7 +395,7 @@ class CI_Loader {
|
||||
|
||||
if ($return === TRUE)
|
||||
{
|
||||
return DB($params, $query_builder);
|
||||
return DB($params);
|
||||
}
|
||||
|
||||
// Initialize the db variable. Needed to prevent
|
||||
@@ -396,7 +403,7 @@ class CI_Loader {
|
||||
$CI->db = '';
|
||||
|
||||
// Load the DB class
|
||||
$CI->db =& DB($params, $query_builder);
|
||||
$CI->db =& DB($params);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -492,7 +499,20 @@ class CI_Loader {
|
||||
*/
|
||||
public function view($view, $vars = array(), $return = FALSE)
|
||||
{
|
||||
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
|
||||
$measure = "View - $view";
|
||||
$CI =& get_instance();
|
||||
|
||||
if (property_exists($CI, "debugbar") && $CI->debugbar) {
|
||||
$CI->debugbar["time"]->startMeasure($measure);
|
||||
}
|
||||
|
||||
$result = $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
|
||||
|
||||
if (property_exists($CI, "debugbar") && $CI->debugbar && $CI->debugbar["time"]->hasStartedMeasure($measure)) {
|
||||
$CI->debugbar["time"]->stopMeasure($measure);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -933,17 +953,38 @@ class CI_Loader {
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract and cache variables
|
||||
* Extract and stack variables
|
||||
*
|
||||
* You can either set variables using the dedicated $this->load->vars()
|
||||
* function or via the second parameter of this function. We'll merge
|
||||
* the two types and cache them so that views that are embedded within
|
||||
* other views can have access to these variables.
|
||||
* the two types so that loaded views and files have access to these
|
||||
* variables.
|
||||
* Additionally we want all subsequent nested _ci_load() calls embedded
|
||||
* within the current file to 'inherit' all variables that are
|
||||
* accessible to the current file. For this purpose we push the current
|
||||
* variable configuration (_ci_vars) to the stack and remove it again
|
||||
* after the file or view is completely loaded. Nested _ci_load() calls
|
||||
* within the current file extend the stack with their variable
|
||||
* configuration.
|
||||
*/
|
||||
empty($_ci_vars) OR $this->_ci_cached_vars = array_merge($this->_ci_cached_vars, $_ci_vars);
|
||||
extract($this->_ci_cached_vars);
|
||||
|
||||
/*
|
||||
is_array($_ci_vars) OR $_ci_vars = array();
|
||||
|
||||
// Include the global cached vars into the current _ci_vars if needed
|
||||
empty($this->_ci_cached_vars) OR $_ci_vars = array_merge($this->_ci_cached_vars, $_ci_vars);
|
||||
|
||||
// Merge the last variable configuration from a parent _ci_load()
|
||||
// call into the current _ci_vars
|
||||
if ( ! empty($this->_ci_load_vars_stack))
|
||||
{
|
||||
$previous_variable_configuration = end($this->_ci_load_vars_stack);
|
||||
$_ci_vars = array_merge($previous_variable_configuration, $_ci_vars);
|
||||
}
|
||||
|
||||
array_push($this->_ci_load_vars_stack, $_ci_vars);
|
||||
extract($_ci_vars);
|
||||
|
||||
/**
|
||||
* Buffer the output
|
||||
*
|
||||
* We buffer the output for two reasons:
|
||||
@@ -956,20 +997,12 @@ class CI_Loader {
|
||||
*/
|
||||
ob_start();
|
||||
|
||||
// If the PHP installation does not support short tags we'll
|
||||
// do a little string replacement, changing the short tags
|
||||
// to standard PHP echo statements.
|
||||
if ( ! is_php('5.4') && ! ini_get('short_open_tag') && config_item('rewrite_short_tags') === TRUE)
|
||||
{
|
||||
echo eval('?>'.preg_replace('/;*\s*\?>/', '; ?>', str_replace('<?=', '<?php echo ', file_get_contents($_ci_path))));
|
||||
}
|
||||
else
|
||||
{
|
||||
include($_ci_path); // include() vs include_once() allows for multiple views with the same name
|
||||
}
|
||||
|
||||
include($_ci_path); // include() vs include_once() allows for multiple views with the same name
|
||||
log_message('info', 'File loaded: '.$_ci_path);
|
||||
|
||||
// Remove current _ci_vars from stack
|
||||
array_pop($this->_ci_load_vars_stack);
|
||||
|
||||
// Return the file data if requested
|
||||
if ($_ci_return === TRUE)
|
||||
{
|
||||
|
||||
+30
-19
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Logging
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/general/errors.html
|
||||
* @link https://codeigniter.com/userguide3/general/errors.html
|
||||
*/
|
||||
class CI_Log {
|
||||
|
||||
@@ -55,6 +56,13 @@ class CI_Log {
|
||||
*/
|
||||
protected $_log_path;
|
||||
|
||||
/**
|
||||
* Log filename
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_log_filename;
|
||||
|
||||
/**
|
||||
* File permissions
|
||||
*
|
||||
@@ -83,13 +91,6 @@ class CI_Log {
|
||||
*/
|
||||
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
|
||||
*
|
||||
@@ -122,11 +123,24 @@ class CI_Log {
|
||||
{
|
||||
$config =& get_config();
|
||||
|
||||
isset(self::$func_overload) OR self::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
|
||||
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';
|
||||
$this->_log_path = ($config['log_path'] !== '')
|
||||
? rtrim($config['log_path'], '/\\').DIRECTORY_SEPARATOR : APPPATH.'logs'.DIRECTORY_SEPARATOR;
|
||||
|
||||
if (isset($config['log_filename']) && $config['log_filename'] !== '')
|
||||
{
|
||||
$this->_log_filename = $config['log_filename'];
|
||||
}
|
||||
elseif (isset($config['log_file_extension']) && $config['log_file_extension'] !== '')
|
||||
{
|
||||
$ext = ltrim($config['log_file_extension'], '.');
|
||||
$this->_log_filename = 'log-'.date('Y-m-d').'.'.$ext;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_log_filename = 'log-'.date('Y-m-d').'.php';
|
||||
}
|
||||
|
||||
file_exists($this->_log_path) OR mkdir($this->_log_path, 0755, TRUE);
|
||||
|
||||
@@ -182,14 +196,14 @@ class CI_Log {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$filepath = $this->_log_path.'log-'.date('Y-m-d').'.'.$this->_file_ext;
|
||||
$filepath = $this->_log_path.$this->_log_filename;
|
||||
$message = '';
|
||||
|
||||
if ( ! file_exists($filepath))
|
||||
{
|
||||
$newfile = TRUE;
|
||||
// Only add protection to php files
|
||||
if ($this->_file_ext === 'php')
|
||||
if (substr($this->_log_filename, -3, 3) === 'php')
|
||||
{
|
||||
$message .= "<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>\n\n";
|
||||
}
|
||||
@@ -217,7 +231,7 @@ class CI_Log {
|
||||
|
||||
$message .= $this->_format_line($level, $date, $msg);
|
||||
|
||||
for ($written = 0, $length = self::strlen($message); $written < $length; $written += $result)
|
||||
for ($result = $written = 0, $length = self::strlen($message); $written < $length; $written += $result)
|
||||
{
|
||||
if (($result = fwrite($fp, self::substr($message, $written))) === FALSE)
|
||||
{
|
||||
@@ -283,9 +297,6 @@ class CI_Log {
|
||||
{
|
||||
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');
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,8 +45,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/config.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/config.html
|
||||
*/
|
||||
#[AllowDynamicProperties]
|
||||
class CI_Model {
|
||||
|
||||
/**
|
||||
|
||||
+21
-19
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Output
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/output.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/output.html
|
||||
*/
|
||||
class CI_Output {
|
||||
|
||||
@@ -55,7 +56,7 @@ class CI_Output {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $final_output;
|
||||
public $final_output = '';
|
||||
|
||||
/**
|
||||
* Cache expiration time
|
||||
@@ -145,7 +146,7 @@ class CI_Output {
|
||||
&& extension_loaded('zlib')
|
||||
);
|
||||
|
||||
isset(self::$func_overload) OR self::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
|
||||
isset(self::$func_overload) OR self::$func_overload = ( ! is_php('8.0') && extension_loaded('mbstring') && @ini_get('mbstring.func_overload'));
|
||||
|
||||
// Get mime types for later
|
||||
$this->mimes =& get_mimes();
|
||||
@@ -299,10 +300,14 @@ class CI_Output {
|
||||
*/
|
||||
public function get_header($header)
|
||||
{
|
||||
// Combine headers already sent with our batched headers
|
||||
// We only need [x][0] from our multi-dimensional array
|
||||
$header_lines = array_map(function ($headers)
|
||||
{
|
||||
return array_shift($headers);
|
||||
}, $this->headers);
|
||||
|
||||
$headers = array_merge(
|
||||
// We only need [x][0] from our multi-dimensional array
|
||||
array_map('array_shift', $this->headers),
|
||||
$header_lines,
|
||||
headers_list()
|
||||
);
|
||||
|
||||
@@ -412,7 +417,7 @@ class CI_Output {
|
||||
* @param string $output Output data override
|
||||
* @return void
|
||||
*/
|
||||
public function _display($output = '')
|
||||
public function _display($output = NULL)
|
||||
{
|
||||
// Note: We use load_class() because we can't use $CI =& get_instance()
|
||||
// since this function is sometimes called by the caching mechanism,
|
||||
@@ -429,7 +434,7 @@ class CI_Output {
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// Set the output data
|
||||
if ($output === '')
|
||||
if ($output === NULL)
|
||||
{
|
||||
$output =& $this->final_output;
|
||||
}
|
||||
@@ -451,7 +456,7 @@ class CI_Output {
|
||||
|
||||
$elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end');
|
||||
|
||||
if ($this->parse_exec_vars === TRUE)
|
||||
if ($this->parse_exec_vars === TRUE && !empty($output))
|
||||
{
|
||||
$memory = round(memory_get_usage() / 1024 / 1024, 2).'MB';
|
||||
$output = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output);
|
||||
@@ -502,7 +507,7 @@ class CI_Output {
|
||||
|
||||
echo $output;
|
||||
log_message('info', 'Final output sent to browser');
|
||||
log_message('debug', 'Total execution time: '.$elapsed);
|
||||
log_message('info', 'Total execution time: '.$elapsed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -539,7 +544,7 @@ class CI_Output {
|
||||
}
|
||||
|
||||
log_message('info', 'Final output sent to browser');
|
||||
log_message('debug', 'Total execution time: '.$elapsed);
|
||||
log_message('info', 'Total execution time: '.$elapsed);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -554,7 +559,7 @@ class CI_Output {
|
||||
{
|
||||
$CI =& get_instance();
|
||||
$path = $CI->config->item('cache_path');
|
||||
$cache_path = ($path === '') ? APPPATH.'cache/' : $path;
|
||||
$cache_path = ($path === '') ? APPPATH.'cache'.DIRECTORY_SEPARATOR : rtrim($path, '/\\').DIRECTORY_SEPARATOR;
|
||||
|
||||
if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path))
|
||||
{
|
||||
@@ -563,7 +568,7 @@ class CI_Output {
|
||||
}
|
||||
|
||||
$uri = $CI->config->item('base_url')
|
||||
.$CI->config->item('index_page')
|
||||
.$CI->config->slash_item('index_page')
|
||||
.$CI->uri->uri_string();
|
||||
|
||||
if (($cache_query_string = $CI->config->item('cache_query_string')) && ! empty($_SERVER['QUERY_STRING']))
|
||||
@@ -658,7 +663,7 @@ class CI_Output {
|
||||
$cache_path = ($CFG->item('cache_path') === '') ? APPPATH.'cache/' : $CFG->item('cache_path');
|
||||
|
||||
// Build the file path. The file name is an MD5 hash of the full URI
|
||||
$uri = $CFG->item('base_url').$CFG->item('index_page').$URI->uri_string;
|
||||
$uri = $CFG->item('base_url').$CFG->slash_item('index_page').$URI->uri_string;
|
||||
|
||||
if (($cache_query_string = $CFG->item('cache_query_string')) && ! empty($_SERVER['QUERY_STRING']))
|
||||
{
|
||||
@@ -761,7 +766,7 @@ class CI_Output {
|
||||
}
|
||||
}
|
||||
|
||||
$cache_path .= md5($CI->config->item('base_url').$CI->config->item('index_page').ltrim($uri, '/'));
|
||||
$cache_path .= md5($CI->config->item('base_url').$CI->config->slash_item('index_page').ltrim($uri, '/'));
|
||||
|
||||
if ( ! @unlink($cache_path))
|
||||
{
|
||||
@@ -829,9 +834,6 @@ class CI_Output {
|
||||
{
|
||||
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');
|
||||
}
|
||||
|
||||
|
||||
+12
-4
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/general/routing.html
|
||||
* @link https://codeigniter.com/userguide3/general/routing.html
|
||||
*/
|
||||
class CI_Router {
|
||||
|
||||
@@ -57,6 +58,13 @@ class CI_Router {
|
||||
*/
|
||||
public $config;
|
||||
|
||||
/**
|
||||
* CI_URI class object
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $uri;
|
||||
|
||||
/**
|
||||
* List of routes
|
||||
*
|
||||
@@ -83,7 +91,7 @@ class CI_Router {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $directory;
|
||||
public $directory = '';
|
||||
|
||||
/**
|
||||
* Default controller (and method if specific)
|
||||
@@ -332,7 +340,7 @@ class CI_Router {
|
||||
protected function _validate_request($segments)
|
||||
{
|
||||
$c = count($segments);
|
||||
$directory_override = isset($this->directory);
|
||||
$directory_override = $this->directory !== '';
|
||||
|
||||
// Loop through our segments and return as soon as a controller
|
||||
// is found or when such a directory doesn't exist
|
||||
|
||||
+42
-45
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Security
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/security.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/security.html
|
||||
*/
|
||||
class CI_Security {
|
||||
|
||||
@@ -169,10 +170,12 @@ class CI_Security {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($charset)
|
||||
{
|
||||
$this->charset = $charset;
|
||||
|
||||
// Is CSRF protection enabled?
|
||||
if (config_item('csrf_protection'))
|
||||
if (config_item('csrf_protection') && ! is_cli())
|
||||
{
|
||||
// CSRF config
|
||||
foreach (array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key)
|
||||
@@ -191,10 +194,9 @@ class CI_Security {
|
||||
|
||||
// Set the CSRF hash
|
||||
$this->_csrf_set_hash();
|
||||
$this->csrf_verify();
|
||||
}
|
||||
|
||||
$this->charset = strtoupper(config_item('charset'));
|
||||
|
||||
log_message('info', 'Security Class Initialized');
|
||||
}
|
||||
|
||||
@@ -272,15 +274,35 @@ class CI_Security {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
setcookie(
|
||||
$this->_csrf_cookie_name,
|
||||
$this->_csrf_hash,
|
||||
$expire,
|
||||
config_item('cookie_path'),
|
||||
config_item('cookie_domain'),
|
||||
$secure_cookie,
|
||||
config_item('cookie_httponly')
|
||||
);
|
||||
if (is_php('7.3'))
|
||||
{
|
||||
setcookie(
|
||||
$this->_csrf_cookie_name,
|
||||
$this->_csrf_hash,
|
||||
array(
|
||||
'expires' => $expire,
|
||||
'path' => config_item('cookie_path'),
|
||||
'domain' => config_item('cookie_domain'),
|
||||
'secure' => $secure_cookie,
|
||||
'httponly' => config_item('cookie_httponly'),
|
||||
'samesite' => 'Strict'
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$domain = trim(config_item('cookie_domain'));
|
||||
header('Set-Cookie: '.$this->_csrf_cookie_name.'='.$this->_csrf_hash
|
||||
.'; Expires='.gmdate('D, d-M-Y H:i:s T', $expire)
|
||||
.'; Max-Age='.$this->_csrf_expire
|
||||
.'; Path='.implode('/', array_map('rawurlencode', explode('/', config_item('cookie_path'))))
|
||||
.($domain === '' ? '' : '; Domain='.$domain)
|
||||
.($secure_cookie ? '; Secure' : '')
|
||||
.(config_item('cookie_httponly') ? '; HttpOnly' : '')
|
||||
.'; SameSite=Strict'
|
||||
);
|
||||
}
|
||||
|
||||
log_message('info', 'CSRF cookie sent');
|
||||
|
||||
return $this;
|
||||
@@ -635,11 +657,10 @@ class CI_Security {
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
if (is_readable('/dev/urandom') && ($fp = fopen('/dev/urandom', 'rb')) !== FALSE)
|
||||
{
|
||||
// Try not to waste entropy ...
|
||||
is_php('5.4') && stream_set_chunk_size($fp, $length);
|
||||
stream_set_chunk_size($fp, $length);
|
||||
$output = fread($fp, $length);
|
||||
fclose($fp);
|
||||
if ($output !== FALSE)
|
||||
@@ -669,7 +690,7 @@ class CI_Security {
|
||||
* correctly. html_entity_decode() does not convert entities without
|
||||
* semicolons, so we are left with our own little solution here. Bummer.
|
||||
*
|
||||
* @link http://php.net/html-entity-decode
|
||||
* @link https://secure.php.net/html-entity-decode
|
||||
*
|
||||
* @param string $str Input
|
||||
* @param string $charset Character set
|
||||
@@ -684,26 +705,8 @@ class CI_Security {
|
||||
|
||||
static $_entities;
|
||||
|
||||
isset($charset) OR $charset = $this->charset;
|
||||
$flag = is_php('5.4')
|
||||
? ENT_COMPAT | ENT_HTML5
|
||||
: ENT_COMPAT;
|
||||
|
||||
if ( ! isset($_entities))
|
||||
{
|
||||
$_entities = array_map('strtolower', get_html_translation_table(HTML_ENTITIES, $flag, $charset));
|
||||
|
||||
// If we're not on PHP 5.4+, add the possibly dangerous HTML 5
|
||||
// entities to the array manually
|
||||
if ($flag === ENT_COMPAT)
|
||||
{
|
||||
$_entities[':'] = ':';
|
||||
$_entities['('] = '(';
|
||||
$_entities[')'] = ')';
|
||||
$_entities["\n"] = '
';
|
||||
$_entities["\t"] = '	';
|
||||
}
|
||||
}
|
||||
isset($charset) OR $charset = $this->charset;
|
||||
isset($_entities) OR $_entities = array_map('strtolower', get_html_translation_table(HTML_ENTITIES, ENT_COMPAT | ENT_HTML5, $charset));
|
||||
|
||||
do
|
||||
{
|
||||
@@ -728,14 +731,9 @@ class CI_Security {
|
||||
// Decode numeric & UTF16 two byte entities
|
||||
$str = html_entity_decode(
|
||||
preg_replace('/(&#(?:x0*[0-9a-f]{2,5}(?![0-9a-f;])|(?:0*\d{2,4}(?![0-9;]))))/iS', '$1;', $str),
|
||||
$flag,
|
||||
ENT_COMPAT | ENT_HTML5,
|
||||
$charset
|
||||
);
|
||||
|
||||
if ($flag === ENT_COMPAT)
|
||||
{
|
||||
$str = str_replace(array_values($_entities), array_keys($_entities), $str);
|
||||
}
|
||||
}
|
||||
while ($str_compare !== $str);
|
||||
return $str;
|
||||
@@ -1087,5 +1085,4 @@ class CI_Security {
|
||||
|
||||
return $this->_csrf_hash;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+80
-54
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,10 +47,17 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category URI
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/uri.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/uri.html
|
||||
*/
|
||||
class CI_URI {
|
||||
|
||||
/**
|
||||
* CI_Config instance
|
||||
*
|
||||
* @var CI_Config
|
||||
*/
|
||||
public $config;
|
||||
|
||||
/**
|
||||
* List of cached URI segments
|
||||
*
|
||||
@@ -96,45 +104,40 @@ class CI_URI {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(CI_Config $config)
|
||||
{
|
||||
$this->config =& load_class('Config', 'core');
|
||||
$this->config = $config;
|
||||
|
||||
// If it's a CLI request, ignore the configuration
|
||||
if (is_cli())
|
||||
{
|
||||
$this->_set_uri_string($this->_parse_argv(), TRUE);
|
||||
}
|
||||
// If query strings are enabled, we don't need to parse any segments.
|
||||
// However, they don't make sense under CLI.
|
||||
if (is_cli() OR $this->config->item('enable_query_strings') !== TRUE)
|
||||
elseif ($this->config->item('enable_query_strings') !== TRUE)
|
||||
{
|
||||
$this->_permitted_uri_chars = $this->config->item('permitted_uri_chars');
|
||||
$protocol = $this->config->item('uri_protocol');
|
||||
empty($protocol) && $protocol = 'REQUEST_URI';
|
||||
|
||||
// If it's a CLI request, ignore the configuration
|
||||
if (is_cli())
|
||||
switch ($protocol)
|
||||
{
|
||||
$uri = $this->_parse_argv();
|
||||
}
|
||||
else
|
||||
{
|
||||
$protocol = $this->config->item('uri_protocol');
|
||||
empty($protocol) && $protocol = 'REQUEST_URI';
|
||||
|
||||
switch ($protocol)
|
||||
{
|
||||
case 'AUTO': // For BC purposes only
|
||||
case 'REQUEST_URI':
|
||||
$uri = $this->_parse_request_uri();
|
||||
break;
|
||||
case 'QUERY_STRING':
|
||||
$uri = $this->_parse_query_string();
|
||||
break;
|
||||
case 'PATH_INFO':
|
||||
default:
|
||||
$uri = isset($_SERVER[$protocol])
|
||||
? $_SERVER[$protocol]
|
||||
: $this->_parse_request_uri();
|
||||
break;
|
||||
}
|
||||
case 'AUTO': // For BC purposes only
|
||||
case 'REQUEST_URI':
|
||||
$uri = $this->_parse_request_uri();
|
||||
break;
|
||||
case 'QUERY_STRING':
|
||||
$uri = $this->_parse_query_string();
|
||||
break;
|
||||
case 'PATH_INFO':
|
||||
default:
|
||||
$uri = isset($_SERVER[$protocol])
|
||||
? $_SERVER[$protocol]
|
||||
: $this->_parse_request_uri();
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_set_uri_string($uri);
|
||||
$this->_set_uri_string($uri, FALSE);
|
||||
}
|
||||
|
||||
log_message('info', 'URI Class Initialized');
|
||||
@@ -145,43 +148,66 @@ class CI_URI {
|
||||
/**
|
||||
* Set URI String
|
||||
*
|
||||
* @param string $str
|
||||
* @param string $str Input URI string
|
||||
* @param bool $is_cli Whether the input comes from CLI
|
||||
* @return void
|
||||
*/
|
||||
protected function _set_uri_string($str)
|
||||
protected function _set_uri_string($str, $is_cli = FALSE)
|
||||
{
|
||||
// Filter out control characters and trim slashes
|
||||
$this->uri_string = trim(remove_invisible_characters($str, FALSE), '/');
|
||||
|
||||
if ($this->uri_string !== '')
|
||||
// CLI requests have a bit simpler logic
|
||||
if ($is_cli)
|
||||
{
|
||||
// Remove the URL suffix, if present
|
||||
if (($suffix = (string) $this->config->item('url_suffix')) !== '')
|
||||
if (($this->uri_string = trim($str, '/')) === '')
|
||||
{
|
||||
$slen = strlen($suffix);
|
||||
|
||||
if (substr($this->uri_string, -$slen) === $suffix)
|
||||
{
|
||||
$this->uri_string = substr($this->uri_string, 0, -$slen);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$this->segments[0] = NULL;
|
||||
// Populate the segments array
|
||||
foreach (explode('/', trim($this->uri_string, '/')) as $val)
|
||||
foreach (explode('/', $this->uri_string) as $segment)
|
||||
{
|
||||
$val = trim($val);
|
||||
// Filter segments for security
|
||||
$this->filter_uri($val);
|
||||
|
||||
if ($val !== '')
|
||||
if (($segment = trim($segment)) !== '')
|
||||
{
|
||||
$this->segments[] = $val;
|
||||
$this->segments[] = $segment;
|
||||
}
|
||||
}
|
||||
|
||||
unset($this->segments[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Filter out control characters and trim slashes
|
||||
$this->uri_string = trim(remove_invisible_characters($str, FALSE), '/');
|
||||
|
||||
if ($this->uri_string === '')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the URL suffix, if present
|
||||
if (($suffix = (string) $this->config->item('url_suffix')) !== '')
|
||||
{
|
||||
$slen = strlen($suffix);
|
||||
|
||||
if (substr($this->uri_string, -$slen) === $suffix)
|
||||
{
|
||||
$this->uri_string = substr($this->uri_string, 0, -$slen);
|
||||
}
|
||||
}
|
||||
|
||||
$this->segments[0] = NULL;
|
||||
foreach (explode('/', trim($this->uri_string, '/')) as $segment)
|
||||
{
|
||||
$segment = trim($segment);
|
||||
// Filter segments for security
|
||||
$this->filter_uri($segment);
|
||||
|
||||
if ($segment !== '')
|
||||
{
|
||||
$this->segments[] = $segment;
|
||||
}
|
||||
}
|
||||
|
||||
unset($this->segments[0]);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
+10
-9
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category UTF-8
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/utf8.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/utf8.html
|
||||
*/
|
||||
class CI_Utf8 {
|
||||
|
||||
@@ -57,21 +58,21 @@ class CI_Utf8 {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($charset)
|
||||
{
|
||||
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
|
||||
)
|
||||
defined('PREG_BAD_UTF8_ERROR') // PCRE must support UTF-8
|
||||
&& (ICONV_ENABLED === TRUE OR MB_ENABLED === TRUE) // iconv or mbstring must be installed
|
||||
&& $charset === 'UTF-8' // Application charset must be UTF-8
|
||||
)
|
||||
{
|
||||
define('UTF8_ENABLED', TRUE);
|
||||
log_message('debug', 'UTF-8 Support Enabled');
|
||||
log_message('info', 'UTF-8 Support Enabled');
|
||||
}
|
||||
else
|
||||
{
|
||||
define('UTF8_ENABLED', FALSE);
|
||||
log_message('debug', 'UTF-8 Support Disabled');
|
||||
log_message('info', 'UTF-8 Support Disabled');
|
||||
}
|
||||
|
||||
log_message('info', 'Utf8 Class Initialized');
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,8 +45,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage CodeIgniter
|
||||
* @category Compatibility
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/
|
||||
* @link http://php.net/hash
|
||||
* @link https://codeigniter.com/userguide3/
|
||||
* @link https://secure.php.net/hash
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -62,7 +63,7 @@ if ( ! function_exists('hash_equals'))
|
||||
/**
|
||||
* hash_equals()
|
||||
*
|
||||
* @link http://php.net/hash_equals
|
||||
* @link https://secure.php.net/hash_equals
|
||||
* @param string $known_string
|
||||
* @param string $user_string
|
||||
* @return bool
|
||||
@@ -108,7 +109,7 @@ if ( ! function_exists('hash_pbkdf2'))
|
||||
/**
|
||||
* hash_pbkdf2()
|
||||
*
|
||||
* @link http://php.net/hash_pbkdf2
|
||||
* @link https://secure.php.net/hash_pbkdf2
|
||||
* @param string $algo
|
||||
* @param string $password
|
||||
* @param string $salt
|
||||
@@ -205,8 +206,6 @@ if ( ! function_exists('hash_pbkdf2'))
|
||||
'ripemd160' => 64,
|
||||
'ripemd256' => 64,
|
||||
'ripemd320' => 64,
|
||||
'salsa10' => 64,
|
||||
'salsa20' => 64,
|
||||
'sha1' => 64,
|
||||
'sha224' => 64,
|
||||
'sha256' => 64,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,8 +45,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage CodeIgniter
|
||||
* @category Compatibility
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/
|
||||
* @link http://php.net/mbstring
|
||||
* @link https://codeigniter.com/userguide3/
|
||||
* @link https://secure.php.net/mbstring
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -65,7 +66,7 @@ if ( ! function_exists('mb_strlen'))
|
||||
* WARNING: This function WILL fall-back to strlen()
|
||||
* if iconv is not available!
|
||||
*
|
||||
* @link http://php.net/mb_strlen
|
||||
* @link https://secure.php.net/mb_strlen
|
||||
* @param string $str
|
||||
* @param string $encoding
|
||||
* @return int
|
||||
@@ -92,7 +93,7 @@ if ( ! function_exists('mb_strpos'))
|
||||
* WARNING: This function WILL fall-back to strpos()
|
||||
* if iconv is not available!
|
||||
*
|
||||
* @link http://php.net/mb_strpos
|
||||
* @link https://secure.php.net/mb_strpos
|
||||
* @param string $haystack
|
||||
* @param string $needle
|
||||
* @param int $offset
|
||||
@@ -121,7 +122,7 @@ if ( ! function_exists('mb_substr'))
|
||||
* WARNING: This function WILL fall-back to substr()
|
||||
* if iconv is not available.
|
||||
*
|
||||
* @link http://php.net/mb_substr
|
||||
* @link https://secure.php.net/mb_substr
|
||||
* @param string $str
|
||||
* @param int $start
|
||||
* @param int $length
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,8 +45,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage CodeIgniter
|
||||
* @category Compatibility
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/
|
||||
* @link http://php.net/password
|
||||
* @link https://codeigniter.com/userguide3/
|
||||
* @link https://secure.php.net/password
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -67,7 +68,7 @@ if ( ! function_exists('password_get_info'))
|
||||
/**
|
||||
* password_get_info()
|
||||
*
|
||||
* @link http://php.net/password_get_info
|
||||
* @link https://secure.php.net/password_get_info
|
||||
* @param string $hash
|
||||
* @return array
|
||||
*/
|
||||
@@ -86,7 +87,7 @@ if ( ! function_exists('password_hash'))
|
||||
/**
|
||||
* password_hash()
|
||||
*
|
||||
* @link http://php.net/password_hash
|
||||
* @link https://secure.php.net/password_hash
|
||||
* @param string $password
|
||||
* @param int $algo
|
||||
* @param array $options
|
||||
@@ -141,7 +142,7 @@ if ( ! function_exists('password_hash'))
|
||||
}
|
||||
|
||||
// Try not to waste entropy ...
|
||||
is_php('5.4') && stream_set_chunk_size($fp, 16);
|
||||
stream_set_chunk_size($fp, 16);
|
||||
|
||||
$options['salt'] = '';
|
||||
for ($read = 0; $read < 16; $read = ($func_overload) ? mb_strlen($options['salt'], '8bit') : strlen($options['salt']))
|
||||
@@ -194,7 +195,7 @@ if ( ! function_exists('password_needs_rehash'))
|
||||
/**
|
||||
* password_needs_rehash()
|
||||
*
|
||||
* @link http://php.net/password_needs_rehash
|
||||
* @link https://secure.php.net/password_needs_rehash
|
||||
* @param string $hash
|
||||
* @param int $algo
|
||||
* @param array $options
|
||||
@@ -228,7 +229,7 @@ if ( ! function_exists('password_verify'))
|
||||
/**
|
||||
* password_verify()
|
||||
*
|
||||
* @link http://php.net/password_verify
|
||||
* @link https://secure.php.net/password_verify
|
||||
* @param string $password
|
||||
* @param string $hash
|
||||
* @return bool
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage CodeIgniter
|
||||
* @category Compatibility
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/
|
||||
* @link https://codeigniter.com/userguide3/
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -61,7 +62,7 @@ if ( ! function_exists('array_column'))
|
||||
/**
|
||||
* array_column()
|
||||
*
|
||||
* @link http://php.net/array_column
|
||||
* @link https://secure.php.net/array_column
|
||||
* @param array $array
|
||||
* @param mixed $column_key
|
||||
* @param mixed $index_key
|
||||
@@ -132,51 +133,3 @@ if ( ! function_exists('array_column'))
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
+18
-42
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,13 +43,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @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)
|
||||
function &DB($params = '')
|
||||
{
|
||||
// Load the DB config file if a DSN string wasn't passed
|
||||
if (is_string($params) && strpos($params, '://') === FALSE)
|
||||
@@ -82,7 +81,7 @@ function &DB($params = '', $query_builder_override = NULL)
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! isset($db) OR count($db) === 0)
|
||||
if (empty($db))
|
||||
{
|
||||
show_error('No database connection settings were found in the database config file.');
|
||||
}
|
||||
@@ -149,53 +148,30 @@ function &DB($params = '', $query_builder_override = NULL)
|
||||
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))
|
||||
require_once(BASEPATH.'database/DB_query_builder.php');
|
||||
if ( ! class_exists('CI_DB', FALSE))
|
||||
{
|
||||
/**
|
||||
* @ignore
|
||||
* 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_driver { }
|
||||
class CI_DB extends CI_DB_query_builder {}
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// Load the result classes as well
|
||||
require_once(BASEPATH.'database/DB_result.php');
|
||||
require_once(BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_result.php');
|
||||
|
||||
// Instantiate the DB adapter
|
||||
$driver = 'CI_DB_'.$params['dbdriver'].'_driver';
|
||||
$DB = new $driver($params);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_Cache {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,8 +49,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
#[AllowDynamicProperties]
|
||||
abstract class CI_DB_driver {
|
||||
|
||||
/**
|
||||
@@ -380,7 +382,8 @@ abstract class CI_DB_driver {
|
||||
/**
|
||||
* Initialize Database Settings
|
||||
*
|
||||
* @return bool
|
||||
* @return void
|
||||
* @throws RuntimeException In case of failure
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
@@ -392,7 +395,7 @@ abstract class CI_DB_driver {
|
||||
*/
|
||||
if ($this->conn_id)
|
||||
{
|
||||
return TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
@@ -429,19 +432,9 @@ abstract class CI_DB_driver {
|
||||
// We still don't have a connection?
|
||||
if ( ! $this->conn_id)
|
||||
{
|
||||
log_message('error', 'Unable to connect to the database');
|
||||
|
||||
if ($this->db_debug)
|
||||
{
|
||||
$this->display_error('db_unable_to_connect');
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
throw new RuntimeException('Unable to connect to the database.');
|
||||
}
|
||||
}
|
||||
|
||||
// Now we set the character set and that's all
|
||||
return $this->db_set_charset($this->char_set);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -516,31 +509,6 @@ abstract class CI_DB_driver {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @param string
|
||||
* @return bool
|
||||
*/
|
||||
public function db_set_charset($charset)
|
||||
{
|
||||
if (method_exists($this, '_db_set_charset') && ! $this->_db_set_charset($charset))
|
||||
{
|
||||
log_message('error', 'Unable to set database connection charset: '.$charset);
|
||||
|
||||
if ($this->db_debug)
|
||||
{
|
||||
$this->display_error('db_unable_to_set_charset', $charset);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The name of the platform in use (mysql, mssql, etc...)
|
||||
*
|
||||
@@ -634,7 +602,6 @@ abstract class CI_DB_driver {
|
||||
// cached query if it exists
|
||||
if ($this->cache_on === TRUE && $return_object === TRUE && $this->_cache_init())
|
||||
{
|
||||
$this->load_rdriver();
|
||||
if (FALSE !== ($cache = $this->CACHE->read($sql)))
|
||||
{
|
||||
return $cache;
|
||||
@@ -718,9 +685,9 @@ abstract class CI_DB_driver {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Load and instantiate the result driver
|
||||
$driver = $this->load_rdriver();
|
||||
$RES = new $driver($this);
|
||||
// Instantiate the driver-specific result class
|
||||
$driver = 'CI_DB_'.$this->dbdriver.'_result';
|
||||
$RES = new $driver($this);
|
||||
|
||||
// Is query caching enabled? If so, we'll serialize the
|
||||
// result object and save it to a cache file.
|
||||
@@ -749,26 +716,6 @@ abstract class CI_DB_driver {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Load the result drivers
|
||||
*
|
||||
* @return string the name of the result class
|
||||
*/
|
||||
public function load_rdriver()
|
||||
{
|
||||
$driver = 'CI_DB_'.$this->dbdriver.'_result';
|
||||
|
||||
if ( ! class_exists($driver, FALSE))
|
||||
{
|
||||
require_once(BASEPATH.'database/DB_result.php');
|
||||
require_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result.php');
|
||||
}
|
||||
|
||||
return $driver;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Simple Query
|
||||
* This is a simplified version of the query() function. Internally
|
||||
@@ -780,14 +727,7 @@ abstract class CI_DB_driver {
|
||||
*/
|
||||
public function simple_query($sql)
|
||||
{
|
||||
if ( ! $this->conn_id)
|
||||
{
|
||||
if ( ! $this->initialize())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
empty($this->conn_id) && $this->initialize();
|
||||
return $this->_execute($sql);
|
||||
}
|
||||
|
||||
@@ -890,6 +830,18 @@ abstract class CI_DB_driver {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns TRUE if a transaction is currently active
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function trans_active()
|
||||
{
|
||||
return (bool) $this->_trans_depth;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Begin Transaction
|
||||
*
|
||||
@@ -1377,10 +1329,11 @@ abstract class CI_DB_driver {
|
||||
*
|
||||
* This function escapes column and table names
|
||||
*
|
||||
* @param mixed
|
||||
* @param mixed $item Identifier to escape
|
||||
* @param bool $split Whether to split identifiers when a dot is encountered
|
||||
* @return mixed
|
||||
*/
|
||||
public function escape_identifiers($item)
|
||||
public function escape_identifiers($item, $split = TRUE)
|
||||
{
|
||||
if ($this->_escape_char === '' OR empty($item) OR in_array($item, $this->_reserved_identifiers))
|
||||
{
|
||||
@@ -1396,27 +1349,27 @@ abstract class CI_DB_driver {
|
||||
return $item;
|
||||
}
|
||||
// Avoid breaking functions and literal values inside queries
|
||||
elseif (ctype_digit($item) OR $item[0] === "'" OR ($this->_escape_char !== '"' && $item[0] === '"') OR strpos($item, '(') !== FALSE)
|
||||
elseif (ctype_digit((string) $item) OR $item[0] === "'" OR ($this->_escape_char !== '"' && $item[0] === '"') OR strpos($item, '(') !== FALSE)
|
||||
{
|
||||
return $item;
|
||||
}
|
||||
|
||||
static $preg_ec = array();
|
||||
static $preg_ec;
|
||||
|
||||
if (empty($preg_ec))
|
||||
{
|
||||
if (is_array($this->_escape_char))
|
||||
{
|
||||
$preg_ec = array(
|
||||
preg_quote($this->_escape_char[0], '/'),
|
||||
preg_quote($this->_escape_char[1], '/'),
|
||||
preg_quote($this->_escape_char[0]),
|
||||
preg_quote($this->_escape_char[1]),
|
||||
$this->_escape_char[0],
|
||||
$this->_escape_char[1]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$preg_ec[0] = $preg_ec[1] = preg_quote($this->_escape_char, '/');
|
||||
$preg_ec[0] = $preg_ec[1] = preg_quote($this->_escape_char);
|
||||
$preg_ec[2] = $preg_ec[3] = $this->_escape_char;
|
||||
}
|
||||
}
|
||||
@@ -1425,11 +1378,13 @@ abstract class CI_DB_driver {
|
||||
{
|
||||
if (strpos($item, '.'.$id) !== FALSE)
|
||||
{
|
||||
return preg_replace('/'.$preg_ec[0].'?([^'.$preg_ec[1].'\.]+)'.$preg_ec[1].'?\./i', $preg_ec[2].'$1'.$preg_ec[3].'.', $item);
|
||||
return preg_replace('#'.$preg_ec[0].'?([^'.$preg_ec[1].'\.]+)'.$preg_ec[1].'?\.#i', $preg_ec[2].'$1'.$preg_ec[3].'.', $item);
|
||||
}
|
||||
}
|
||||
|
||||
return preg_replace('/'.$preg_ec[0].'?([^'.$preg_ec[1].'\.]+)'.$preg_ec[1].'?(\.)?/i', $preg_ec[2].'$1'.$preg_ec[3].'$2', $item);
|
||||
$dot = ($split !== FALSE) ? '\.' : '';
|
||||
|
||||
return preg_replace('#'.$preg_ec[0].'?([^'.$preg_ec[1].$dot.']+)'.$preg_ec[1].'?(\.)?#i', $preg_ec[2].'$1'.$preg_ec[3].'$2', $item);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1564,6 +1519,7 @@ abstract class CI_DB_driver {
|
||||
'\s+EXISTS\s*\(.*\)', // EXISTS(sql)
|
||||
'\s+NOT EXISTS\s*\(.*\)', // NOT EXISTS(sql)
|
||||
'\s+BETWEEN\s+', // BETWEEN value AND value
|
||||
'\s+NOT BETWEEN\s+', // NOT BETWEEN value AND value
|
||||
'\s+IN\s*\(.*\)', // IN(list)
|
||||
'\s+NOT IN\s*\(.*\)', // NOT IN (list)
|
||||
'\s+LIKE\s+\S.*('.$_les.')?', // LIKE 'expr'[ ESCAPE '%s']
|
||||
@@ -1843,14 +1799,14 @@ abstract class CI_DB_driver {
|
||||
if ($offset = strripos($item, ' AS '))
|
||||
{
|
||||
$alias = ($protect_identifiers)
|
||||
? substr($item, $offset, 4).$this->escape_identifiers(substr($item, $offset + 4))
|
||||
? substr($item, $offset, 4).$this->escape_identifiers(substr($item, $offset + 4), FALSE)
|
||||
: substr($item, $offset);
|
||||
$item = substr($item, 0, $offset);
|
||||
}
|
||||
elseif ($offset = strrpos($item, ' '))
|
||||
{
|
||||
$alias = ($protect_identifiers)
|
||||
? ' '.$this->escape_identifiers(substr($item, $offset + 1))
|
||||
? ' '.$this->escape_identifiers(substr($item, $offset + 1), FALSE)
|
||||
: substr($item, $offset);
|
||||
$item = substr($item, 0, $offset);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
abstract class CI_DB_forge {
|
||||
|
||||
@@ -556,10 +557,8 @@ abstract class CI_DB_forge {
|
||||
/**
|
||||
* Column Add
|
||||
*
|
||||
* @todo Remove deprecated $_after option in 3.1+
|
||||
* @param string $table Table name
|
||||
* @param array $field Column definition
|
||||
* @param string $_after Column for AFTER clause (deprecated)
|
||||
* @return bool
|
||||
*/
|
||||
public function add_column($table, $field, $_after = NULL)
|
||||
@@ -569,7 +568,6 @@ abstract class CI_DB_forge {
|
||||
|
||||
foreach (array_keys($field) as $k)
|
||||
{
|
||||
// Backwards-compatibility work-around for MySQL/CUBRID AFTER clause (remove in 3.1+)
|
||||
if ($_after !== NULL && is_array($field[$k]) && ! isset($field[$k]['after']))
|
||||
{
|
||||
$field[$k]['after'] = $_after;
|
||||
@@ -895,21 +893,33 @@ abstract class CI_DB_forge {
|
||||
return;
|
||||
}
|
||||
|
||||
if (array_key_exists('DEFAULT', $attributes))
|
||||
if ( ! array_key_exists('DEFAULT', $attributes))
|
||||
{
|
||||
if ($attributes['DEFAULT'] === NULL)
|
||||
{
|
||||
$field['default'] = empty($this->_null) ? '' : $this->_default.$this->_null;
|
||||
|
||||
// Override the NULL attribute if that's our default
|
||||
$attributes['NULL'] = TRUE;
|
||||
$field['null'] = empty($this->_null) ? '' : ' '.$this->_null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$field['default'] = $this->_default.$this->db->escape($attributes['DEFAULT']);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($attributes['DEFAULT'] === NULL)
|
||||
{
|
||||
$field['default'] = empty($this->_null) ? '' : $this->_default.$this->_null;
|
||||
|
||||
// Override the NULL attribute if that's our default
|
||||
$attributes['NULL'] = TRUE;
|
||||
$field['null'] = empty($this->_null) ? '' : ' '.$this->_null;
|
||||
return;
|
||||
}
|
||||
|
||||
// White-list CURRENT_TIMESTAMP & similar (e.g. Oracle has stuff like SYSTIMESTAMP) defaults for date/time fields
|
||||
if (
|
||||
isset($attributes['TYPE'])
|
||||
&& (stripos($attributes['TYPE'], 'time') !== FALSE OR stripos($attributes['TYPE'], 'date') !== FALSE)
|
||||
&& (stripos($attributes['DEFAULT'], 'time') !== FALSE OR stripos($attributes['DEFAULT'], 'date') !== FALSE)
|
||||
)
|
||||
{
|
||||
$field['default'] = $this->_default.$attributes['DEFAULT'];
|
||||
return;
|
||||
}
|
||||
|
||||
$field['default'] = $this->_default.$this->db->escape($attributes['DEFAULT']);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
|
||||
abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
@@ -70,7 +71,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $qb_select = array();
|
||||
public $qb_select = array();
|
||||
|
||||
/**
|
||||
* QB DISTINCT flag
|
||||
@@ -140,7 +141,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $qb_orderby = array();
|
||||
public $qb_orderby = array();
|
||||
|
||||
/**
|
||||
* QB data sets
|
||||
@@ -293,7 +294,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
|
||||
foreach ($select as $val)
|
||||
{
|
||||
$val = trim($val);
|
||||
$val = trim((string)$val);
|
||||
|
||||
if ($val !== '')
|
||||
{
|
||||
@@ -407,10 +408,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
|
||||
if ($alias === '')
|
||||
{
|
||||
$alias = $this->_create_alias_from_table(trim($select));
|
||||
$alias = $this->_create_alias_from_table(trim((string)$select));
|
||||
}
|
||||
|
||||
$sql = $type.'('.$this->protect_identifiers(trim($select)).') AS '.$this->escape_identifiers(trim($alias));
|
||||
$sql = $type.'('.$this->protect_identifiers(trim((string)$select)).') AS '.$this->escape_identifiers(trim((string)$alias));
|
||||
|
||||
$this->qb_select[] = $sql;
|
||||
$this->qb_no_escape[] = NULL;
|
||||
@@ -477,7 +478,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
{
|
||||
foreach (explode(',', $val) as $v)
|
||||
{
|
||||
$v = trim($v);
|
||||
$v = trim((string)$v);
|
||||
$this->_track_aliases($v);
|
||||
|
||||
$this->qb_from[] = $v = $this->protect_identifiers($v, TRUE, NULL, FALSE);
|
||||
@@ -491,7 +492,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
}
|
||||
else
|
||||
{
|
||||
$val = trim($val);
|
||||
$val = trim((string)$val);
|
||||
|
||||
// Extract any aliases that might exist. We use this information
|
||||
// in the protect_identifiers to know whether to add a table prefix
|
||||
@@ -525,27 +526,28 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
*/
|
||||
public function join($table, $cond, $type = '', $escape = NULL)
|
||||
{
|
||||
if ($type !== '')
|
||||
{
|
||||
$type = strtoupper(trim($type));
|
||||
|
||||
if ( ! in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER'), TRUE))
|
||||
{
|
||||
$type = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$type .= ' ';
|
||||
}
|
||||
if ($type === null) {
|
||||
$type = '';
|
||||
}
|
||||
|
||||
if (!is_string($type)) {
|
||||
throw new InvalidArgumentException('join() expects parameter 3 to be a string, ' . gettype($type) . ' given');
|
||||
}
|
||||
|
||||
$type = trim((string)strtoupper($type).' JOIN');
|
||||
preg_match('#^(NATURAL\s+)?((LEFT|RIGHT|FULL)\s+)?((INNER|OUTER)\s+)?JOIN$#', $type) OR $type = 'JOIN';
|
||||
|
||||
// Extract any aliases that might exist. We use this information
|
||||
// in the protect_identifiers to know whether to add a table prefix
|
||||
$this->_track_aliases($table);
|
||||
|
||||
is_bool($escape) OR $escape = $this->_protect_identifiers;
|
||||
|
||||
if ( ! $this->_has_operator($cond))
|
||||
if (strpos($type, 'NATURAL') === 0)
|
||||
{
|
||||
$cond = '';
|
||||
}
|
||||
elseif ( ! $this->_has_operator($cond))
|
||||
{
|
||||
$cond = ' USING ('.($escape ? $this->escape_identifiers($cond) : $cond).')';
|
||||
}
|
||||
@@ -594,7 +596,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
}
|
||||
|
||||
// Assemble the JOIN statement
|
||||
$this->qb_join[] = $join = $type.'JOIN '.$table.$cond;
|
||||
$this->qb_join[] = $join = $type.' '.$table.$cond;
|
||||
|
||||
if ($this->qb_caching === TRUE)
|
||||
{
|
||||
@@ -698,11 +700,11 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
$k = substr($k, 0, $match[0][1]).($match[1][0] === '=' ? ' IS NULL' : ' IS NOT NULL');
|
||||
}
|
||||
|
||||
${$qb_key} = array('condition' => $prefix.$k, 'value' => $v, 'escape' => $escape);
|
||||
$this->{$qb_key}[] = ${$qb_key};
|
||||
$$qb_key = array('condition' => $prefix.$k, 'value' => $v, 'escape' => $escape);
|
||||
$this->{$qb_key}[] = $$qb_key;
|
||||
if ($this->qb_caching === TRUE)
|
||||
{
|
||||
$this->{$qb_cache_key}[] = ${$qb_key};
|
||||
$this->{$qb_cache_key}[] = $$qb_key;
|
||||
$this->qb_cache_exists[] = substr($qb_key, 3);
|
||||
}
|
||||
|
||||
@@ -724,9 +726,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
* @param bool $escape
|
||||
* @return CI_DB_query_builder
|
||||
*/
|
||||
public function where_in($key = NULL, $values = NULL, $escape = NULL)
|
||||
public function where_in($key, array $values, $escape = NULL)
|
||||
{
|
||||
return $this->_where_in($key, $values, FALSE, 'AND ', $escape);
|
||||
return $this->_wh_in('qb_where', $key, $values, FALSE, 'AND ', $escape);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -742,9 +744,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
* @param bool $escape
|
||||
* @return CI_DB_query_builder
|
||||
*/
|
||||
public function or_where_in($key = NULL, $values = NULL, $escape = NULL)
|
||||
public function or_where_in($key, array $values, $escape = NULL)
|
||||
{
|
||||
return $this->_where_in($key, $values, FALSE, 'OR ', $escape);
|
||||
return $this->_wh_in('qb_where', $key, $values, FALSE, 'OR ', $escape);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -760,9 +762,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
* @param bool $escape
|
||||
* @return CI_DB_query_builder
|
||||
*/
|
||||
public function where_not_in($key = NULL, $values = NULL, $escape = NULL)
|
||||
public function where_not_in($key, array $values, $escape = NULL)
|
||||
{
|
||||
return $this->_where_in($key, $values, TRUE, 'AND ', $escape);
|
||||
return $this->_wh_in('qb_where', $key, $values, TRUE, 'AND ', $escape);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -778,21 +780,98 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
* @param bool $escape
|
||||
* @return CI_DB_query_builder
|
||||
*/
|
||||
public function or_where_not_in($key = NULL, $values = NULL, $escape = NULL)
|
||||
public function or_where_not_in($key, array $values, $escape = NULL)
|
||||
{
|
||||
return $this->_where_in($key, $values, TRUE, 'OR ', $escape);
|
||||
return $this->_wh_in('qb_where', $key, $values, TRUE, 'OR ', $escape);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Internal WHERE IN
|
||||
* HAVING IN
|
||||
*
|
||||
* Generates a HAVING field IN('item', 'item') SQL query,
|
||||
* joined with 'AND' if appropriate.
|
||||
*
|
||||
* @param string $key The field to search
|
||||
* @param array $values The values searched on
|
||||
* @param bool $escape
|
||||
* @return CI_DB_query_builder
|
||||
*/
|
||||
public function having_in($key, array $values, $escape = NULL)
|
||||
{
|
||||
return $this->_wh_in('qb_having', $key, $values, FALSE, 'AND ', $escape);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* OR HAVING IN
|
||||
*
|
||||
* Generates a HAVING field IN('item', 'item') SQL query,
|
||||
* joined with 'OR' if appropriate.
|
||||
*
|
||||
* @param string $key The field to search
|
||||
* @param array $values The values searched on
|
||||
* @param bool $escape
|
||||
* @return CI_DB_query_builder
|
||||
*/
|
||||
public function or_having_in($key, array $values, $escape = NULL)
|
||||
{
|
||||
return $this->_wh_in('qb_having', $key, $values, FALSE, 'OR ', $escape);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* HAVING NOT IN
|
||||
*
|
||||
* Generates a HAVING field NOT IN('item', 'item') SQL query,
|
||||
* joined with 'AND' if appropriate.
|
||||
*
|
||||
* @param string $key The field to search
|
||||
* @param array $values The values searched on
|
||||
* @param bool $escape
|
||||
* @return CI_DB_query_builder
|
||||
*/
|
||||
public function having_not_in($key, array $values, $escape = NULL)
|
||||
{
|
||||
return $this->_wh_in('qb_having', $key, $values, TRUE, 'AND ', $escape);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* OR HAVING NOT IN
|
||||
*
|
||||
* Generates a HAVING field NOT IN('item', 'item') SQL query,
|
||||
* joined with 'OR' if appropriate.
|
||||
*
|
||||
* @param string $key The field to search
|
||||
* @param array $values The values searched on
|
||||
* @param bool $escape
|
||||
* @return CI_DB_query_builder
|
||||
*/
|
||||
public function or_having_not_in($key, array $values, $escape = NULL)
|
||||
{
|
||||
return $this->_wh_in('qb_having', $key, $values, TRUE, 'OR ', $escape);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Internal WHERE/HAVING IN
|
||||
*
|
||||
* @used-by where_in()
|
||||
* @used-by or_where_in()
|
||||
* @used-by where_not_in()
|
||||
* @used-by or_where_not_in()
|
||||
* @used-by having_in()
|
||||
* @used-by or_having_in()
|
||||
* @used-by having_not_in()
|
||||
* @used-by or_having_not_in()
|
||||
*
|
||||
* @param string $qb_key 'qb_where' or 'qb_having'
|
||||
* @param string $key The field to search
|
||||
* @param array $values The values searched on
|
||||
* @param bool $not If the statement would be IN or NOT IN
|
||||
@@ -800,16 +879,18 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
* @param bool $escape
|
||||
* @return CI_DB_query_builder
|
||||
*/
|
||||
protected function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ', $escape = NULL)
|
||||
protected function _wh_in($qb_key, $key, array $values, $not = FALSE, $type = 'AND ', $escape = NULL)
|
||||
{
|
||||
if ($key === NULL OR $values === NULL)
|
||||
$qb_cache_key = ($qb_key === 'qb_having') ? 'qb_cache_having' : 'qb_cache_where';
|
||||
|
||||
if (empty($key) OR ! is_string($key))
|
||||
{
|
||||
return $this;
|
||||
throw new InvalidArgumentException(sprintf('%s() expects $key to be a non-empty string', debug_backtrace(0, 2)[1]['function']));
|
||||
}
|
||||
|
||||
if ( ! is_array($values))
|
||||
if (empty($values))
|
||||
{
|
||||
$values = array($values);
|
||||
throw new InvalidArgumentException(sprintf('%s() expects $values to be a non-empty array', debug_backtrace(0, 2)[1]['function']));
|
||||
}
|
||||
|
||||
is_bool($escape) OR $escape = $this->_protect_identifiers;
|
||||
@@ -818,32 +899,32 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
|
||||
if ($escape === TRUE)
|
||||
{
|
||||
$where_in = array();
|
||||
$wh_in = array();
|
||||
foreach ($values as $value)
|
||||
{
|
||||
$where_in[] = $this->escape($value);
|
||||
$wh_in[] = $this->escape($value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$where_in = array_values($values);
|
||||
$wh_in = array_values($values);
|
||||
}
|
||||
|
||||
$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0)
|
||||
$prefix = (count($this->$qb_key) === 0 && count($this->$qb_cache_key) === 0)
|
||||
? $this->_group_get_type('')
|
||||
: $this->_group_get_type($type);
|
||||
|
||||
$where_in = array(
|
||||
'condition' => $prefix.$key.$not.' IN('.implode(', ', $where_in).')',
|
||||
$wh_in = array(
|
||||
'condition' => $prefix.$key.$not.' IN('.implode(', ', $wh_in).')',
|
||||
'value' => NULL,
|
||||
'escape' => $escape
|
||||
);
|
||||
|
||||
$this->qb_where[] = $where_in;
|
||||
$this->{$qb_key}[] = $wh_in;
|
||||
if ($this->qb_caching === TRUE)
|
||||
{
|
||||
$this->qb_cache_where[] = $where_in;
|
||||
$this->qb_cache_exists[] = 'where';
|
||||
$this->{$qb_cache_key}[] = $wh_in;
|
||||
$this->qb_cache_exists[] = substr($qb_key, 3);
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -1119,7 +1200,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
/**
|
||||
* GROUP BY
|
||||
*
|
||||
* @param string $by
|
||||
* @param mixed $by
|
||||
* @param bool $escape
|
||||
* @return CI_DB_query_builder
|
||||
*/
|
||||
@@ -1136,7 +1217,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
|
||||
foreach ($by as $val)
|
||||
{
|
||||
$val = trim($val);
|
||||
$val = trim((string)$val);
|
||||
|
||||
if ($val !== '')
|
||||
{
|
||||
@@ -1200,7 +1281,15 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
*/
|
||||
public function order_by($orderby, $direction = '', $escape = NULL)
|
||||
{
|
||||
$direction = strtoupper(trim($direction));
|
||||
if ($direction === null) {
|
||||
$direction = '';
|
||||
}
|
||||
|
||||
if (!is_string($direction)) {
|
||||
throw new InvalidArgumentException('order_by() expects parameter 2 to be a string, ' . gettype($direction) . ' given');
|
||||
}
|
||||
|
||||
$direction = strtoupper(trim((string)$direction));
|
||||
|
||||
if ($direction === 'RANDOM')
|
||||
{
|
||||
@@ -1231,9 +1320,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
$qb_orderby = array();
|
||||
foreach (explode(',', $orderby) as $field)
|
||||
{
|
||||
$qb_orderby[] = ($direction === '' && preg_match('/\s+(ASC|DESC)$/i', rtrim($field), $match, PREG_OFFSET_CAPTURE))
|
||||
? array('field' => ltrim(substr($field, 0, $match[0][1])), 'direction' => ' '.$match[1][0], 'escape' => TRUE)
|
||||
: array('field' => trim($field), 'direction' => $direction, 'escape' => TRUE);
|
||||
$qb_orderby[] = ($direction === '' && preg_match('/\s+(ASC|DESC)$/i', rtrim((string)$field), $match, PREG_OFFSET_CAPTURE))
|
||||
? array('field' => ltrim((string)substr($field, 0, $match[0][1])), 'direction' => ' '.$match[1][0], 'escape' => TRUE)
|
||||
: array('field' => trim((string)$field), 'direction' => $direction, 'escape' => TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1412,7 +1501,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
$qb_cache_orderby = $this->qb_cache_orderby;
|
||||
$this->qb_orderby = $this->qb_cache_orderby = array();
|
||||
|
||||
$result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby) OR ! empty($this->qb_cache_groupby) OR $this->qb_limit OR $this->qb_offset)
|
||||
$result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby) OR ! empty($this->qb_cache_groupby) OR ! empty($this->qb_having) OR $this->qb_limit OR $this->qb_offset)
|
||||
? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")
|
||||
: $this->query($this->_compile_select($this->_count_string.$this->protect_identifiers('numrows')));
|
||||
|
||||
@@ -2288,7 +2377,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
$table = preg_replace('/\s+AS\s+/i', ' ', $table);
|
||||
|
||||
// Grab the alias
|
||||
$table = trim(strrchr($table, ' '));
|
||||
$table = trim((string)strrchr($table, ' '));
|
||||
|
||||
// Store the alias, if it doesn't already exist
|
||||
if ( ! in_array($table, $this->qb_aliased_tables, TRUE))
|
||||
@@ -2431,12 +2520,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
|
||||
if ( ! empty($matches[4]))
|
||||
{
|
||||
$this->_is_literal($matches[4]) OR $matches[4] = $this->protect_identifiers(trim($matches[4]));
|
||||
$this->_is_literal($matches[4]) OR $matches[4] = $this->protect_identifiers(trim((string)$matches[4]));
|
||||
$matches[4] = ' '.$matches[4];
|
||||
}
|
||||
|
||||
$conditions[$ci] = $matches[1].$this->protect_identifiers(trim($matches[2]))
|
||||
.' '.trim($matches[3]).$matches[4].$matches[5];
|
||||
$conditions[$ci] = $matches[1].$this->protect_identifiers(trim((string)$matches[2]))
|
||||
.' '.trim((string)$matches[3]).$matches[4].$matches[5];
|
||||
}
|
||||
|
||||
$this->{$qb_key}[$i] = implode('', $conditions).(isset($this->{$qb_key}[$i]['value']) ? ' '.$this->{$qb_key}[$i]['value'] : '');
|
||||
@@ -2707,7 +2796,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||
*/
|
||||
protected function _is_literal($str)
|
||||
{
|
||||
$str = trim($str);
|
||||
$str = trim((string)$str);
|
||||
|
||||
if (empty($str) OR ctype_digit($str) OR (string) (float) $str === $str OR in_array(strtoupper($str), array('TRUE', 'FALSE'), TRUE))
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_result {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
abstract class CI_DB_utility {
|
||||
|
||||
@@ -235,13 +236,8 @@ abstract class CI_DB_utility {
|
||||
* @param string $enclosure Enclosure (default: ")
|
||||
* @return string
|
||||
*/
|
||||
public function csv_from_result($query, $delim = ',', $newline = "\n", $enclosure = '"')
|
||||
public function csv_from_result(CI_DB_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)
|
||||
@@ -257,7 +253,7 @@ abstract class CI_DB_utility {
|
||||
$line = array();
|
||||
foreach ($row as $item)
|
||||
{
|
||||
$line[] = $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure;
|
||||
$line[] = $enclosure.str_replace($enclosure, $enclosure.$enclosure, (string) $item).$enclosure;
|
||||
}
|
||||
$out .= implode($delim, $line).$newline;
|
||||
}
|
||||
@@ -274,13 +270,8 @@ abstract class CI_DB_utility {
|
||||
* @param array $params Any preferences
|
||||
* @return string
|
||||
*/
|
||||
public function xml_from_result($query, $params = array())
|
||||
public function xml_from_result(CI_DB_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)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author Esen Sagynov
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_cubrid_driver extends CI_DB {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author Esen Sagynov
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_cubrid_forge extends CI_DB_forge {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author Esen Sagynov
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_cubrid_result extends CI_DB_result {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author Esen Sagynov
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_cubrid_utility extends CI_DB_utility {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_ibase_driver extends CI_DB {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_ibase_forge extends CI_DB_forge {
|
||||
|
||||
@@ -140,7 +141,7 @@ class CI_DB_ibase_forge extends CI_DB_forge {
|
||||
* @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);
|
||||
@@ -183,7 +184,7 @@ class CI_DB_ibase_forge extends CI_DB_forge {
|
||||
}
|
||||
|
||||
return $sqls;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_ibase_result extends CI_DB_result {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_ibase_utility extends CI_DB_utility {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_mssql_driver extends CI_DB {
|
||||
|
||||
@@ -108,6 +109,7 @@ class CI_DB_mssql_driver extends CI_DB {
|
||||
*/
|
||||
public function db_connect($persistent = FALSE)
|
||||
{
|
||||
ini_set('mssql.charset', $this->char_set);
|
||||
$this->conn_id = ($persistent)
|
||||
? mssql_pconnect($this->hostname, $this->username, $this->password)
|
||||
: mssql_connect($this->hostname, $this->username, $this->password);
|
||||
@@ -248,19 +250,6 @@ class CI_DB_mssql_driver extends CI_DB {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @param string $charset
|
||||
* @return bool
|
||||
*/
|
||||
protected function _db_set_charset($charset)
|
||||
{
|
||||
return (ini_set('mssql.charset', $charset) !== FALSE);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Version number query string
|
||||
*
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_mssql_forge extends CI_DB_forge {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_mssql_result extends CI_DB_result {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_mssql_utility extends CI_DB_utility {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_mysql_driver extends CI_DB {
|
||||
|
||||
@@ -147,29 +148,41 @@ class CI_DB_mysql_driver extends CI_DB {
|
||||
: FALSE;
|
||||
}
|
||||
|
||||
if (isset($this->stricton) && is_resource($this->conn_id))
|
||||
if (is_resource($this->conn_id))
|
||||
{
|
||||
if ($this->stricton)
|
||||
if ( ! mysql_set_charset($this->char_set, $this->conn_id))
|
||||
{
|
||||
$this->simple_query('SET SESSION sql_mode = CONCAT(@@sql_mode, ",", "STRICT_ALL_TABLES")');
|
||||
log_message('error', "Database: Unable to set the configured connection charset ('{$this->char_set}').");
|
||||
$this->close();
|
||||
return ($this->db->debug) ? $this->display_error('db_unable_to_set_charset', $this->char_set) : FALSE;
|
||||
}
|
||||
else
|
||||
|
||||
if (isset($this->stricton))
|
||||
{
|
||||
$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", "")'
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
||||
return $this->conn_id;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -217,19 +230,6 @@ class CI_DB_mysql_driver extends CI_DB {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_mysql_forge extends CI_DB_forge {
|
||||
|
||||
@@ -185,7 +186,6 @@ class CI_DB_mysql_forge extends CI_DB_forge {
|
||||
$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']
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_mysql_result extends CI_DB_result {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_mysql_utility extends CI_DB_utility {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_mysqli_driver extends CI_DB {
|
||||
|
||||
@@ -116,6 +117,13 @@ class CI_DB_mysqli_driver extends CI_DB {
|
||||
*/
|
||||
public function db_connect($persistent = FALSE)
|
||||
{
|
||||
// PHP 8.1 changes default error handling mode from silent to exceptions - reverse that
|
||||
if (is_php('8.1'))
|
||||
{
|
||||
$mysqli_driver = new mysqli_driver();
|
||||
$mysqli_driver->report_mode = MYSQLI_REPORT_OFF;
|
||||
}
|
||||
|
||||
// Do we have a socket path?
|
||||
if ($this->hostname[0] === '/')
|
||||
{
|
||||
@@ -215,6 +223,13 @@ class CI_DB_mysqli_driver extends CI_DB {
|
||||
return ($this->db_debug) ? $this->display_error($message, '', TRUE) : FALSE;
|
||||
}
|
||||
|
||||
if ( ! $this->_mysqli->set_charset($this->char_set))
|
||||
{
|
||||
log_message('error', "Database: Unable to set the configured connection charset ('{$this->char_set}').");
|
||||
$this->_mysqli->close();
|
||||
return ($this->db->db_debug) ? $this->display_error('db_unable_to_set_charset', $this->char_set) : FALSE;
|
||||
}
|
||||
|
||||
return $this->_mysqli;
|
||||
}
|
||||
|
||||
@@ -266,19 +281,6 @@ class CI_DB_mysqli_driver extends CI_DB {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @param string $charset
|
||||
* @return bool
|
||||
*/
|
||||
protected function _db_set_charset($charset)
|
||||
{
|
||||
return $this->conn_id->set_charset($charset);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Database version number
|
||||
*
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_mysqli_forge extends CI_DB_forge {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_mysqli_result extends CI_DB_result {
|
||||
|
||||
@@ -152,7 +153,6 @@ class CI_DB_mysqli_result extends CI_DB_result {
|
||||
MYSQLI_TYPE_DATETIME => 'datetime',
|
||||
MYSQLI_TYPE_YEAR => 'year',
|
||||
MYSQLI_TYPE_NEWDATE => 'date',
|
||||
MYSQLI_TYPE_INTERVAL => 'interval',
|
||||
MYSQLI_TYPE_ENUM => 'enum',
|
||||
MYSQLI_TYPE_SET => 'set',
|
||||
MYSQLI_TYPE_TINY_BLOB => 'tinyblob',
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_mysqli_utility extends CI_DB_utility {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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.4.1
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -68,20 +69,6 @@ class CI_DB_oci8_driver extends CI_DB {
|
||||
*/
|
||||
public $dbdriver = 'oci8';
|
||||
|
||||
/**
|
||||
* Statement ID
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
public $stmt_id;
|
||||
|
||||
/**
|
||||
* Cursor ID
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
public $curs_id;
|
||||
|
||||
/**
|
||||
* Commit mode flag
|
||||
*
|
||||
@@ -99,15 +86,27 @@ class CI_DB_oci8_driver extends CI_DB {
|
||||
*/
|
||||
public $limit_used = FALSE;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
/**
|
||||
* Error cache
|
||||
*
|
||||
* Cached error info about failed queries.
|
||||
* Used so that statement IDs can be released immediately.
|
||||
*
|
||||
* @var array|false
|
||||
*/
|
||||
protected $_error = FALSE;
|
||||
|
||||
/**
|
||||
* Reset $stmt_id flag
|
||||
* Affected rows
|
||||
*
|
||||
* Used by stored_procedure() to prevent _execute() from
|
||||
* re-setting the statement ID.
|
||||
* Cached result of oci_num_rows().
|
||||
* Used so that statement IDs can be released immediately.
|
||||
*
|
||||
* @var int|false
|
||||
*/
|
||||
protected $_reset_stmt_id = TRUE;
|
||||
protected $_affected_rows = FALSE;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* List of reserved identifiers
|
||||
@@ -178,7 +177,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
||||
return;
|
||||
}
|
||||
elseif ($this->hostname !== '' && strpos($this->hostname, '/') === FALSE && strpos($this->hostname, ':') === FALSE
|
||||
&& (( ! empty($this->port) && ctype_digit($this->port)) OR $this->database !== ''))
|
||||
&& (( ! empty($this->port) && ctype_digit((string) $this->port)) OR $this->database !== ''))
|
||||
{
|
||||
/* If the hostname field isn't empty, doesn't contain
|
||||
* ':' and/or '/' and if port and/or database aren't
|
||||
@@ -188,7 +187,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
||||
* that the database field is a service name.
|
||||
*/
|
||||
$this->dsn = $this->hostname
|
||||
.(( ! empty($this->port) && ctype_digit($this->port)) ? ':'.$this->port : '')
|
||||
.(( ! empty($this->port) && ctype_digit((string) $this->port)) ? ':'.$this->port : '')
|
||||
.($this->database !== '' ? '/'.ltrim($this->database, '/') : '');
|
||||
|
||||
if (preg_match($valid_dsns['ec'], $this->dsn))
|
||||
@@ -277,104 +276,19 @@ class CI_DB_oci8_driver extends CI_DB {
|
||||
/* Oracle must parse the query before it is run. All of the actions with
|
||||
* the query are based on the statement id returned by oci_parse().
|
||||
*/
|
||||
if ($this->_reset_stmt_id === TRUE)
|
||||
$this->result_id = oci_parse($this->conn_id, $sql);
|
||||
oci_set_prefetch($this->result_id, 1000);
|
||||
$result = oci_execute($this->result_id, $this->commit_mode);
|
||||
$this->_error = oci_error($this->result_id);
|
||||
$this->is_write_type($sql) && $this->_affected_rows = oci_num_rows($this->result_id);
|
||||
|
||||
if ($this->is_write_type($sql) OR $result === FALSE)
|
||||
{
|
||||
$this->stmt_id = oci_parse($this->conn_id, $sql);
|
||||
oci_free_statement($this->result_id);
|
||||
return $result;
|
||||
}
|
||||
|
||||
oci_set_prefetch($this->stmt_id, 1000);
|
||||
return oci_execute($this->stmt_id, $this->commit_mode);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get cursor. Returns a cursor from the database
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function get_cursor()
|
||||
{
|
||||
return $this->curs_id = oci_new_cursor($this->conn_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Stored Procedure. Executes a stored procedure
|
||||
*
|
||||
* @param string package name in which the stored procedure is in
|
||||
* @param string stored procedure name to execute
|
||||
* @param array parameters
|
||||
* @return mixed
|
||||
*
|
||||
* params array keys
|
||||
*
|
||||
* KEY OPTIONAL NOTES
|
||||
* name no the name of the parameter should be in :<param_name> format
|
||||
* value no the value of the parameter. If this is an OUT or IN OUT parameter,
|
||||
* this should be a reference to a variable
|
||||
* type yes the type of the parameter
|
||||
* length yes the max size of the parameter
|
||||
*/
|
||||
public function stored_procedure($package, $procedure, array $params)
|
||||
{
|
||||
if ($package === '' OR $procedure === '')
|
||||
{
|
||||
log_message('error', 'Invalid query: '.$package.'.'.$procedure);
|
||||
return ($this->db_debug) ? $this->display_error('db_invalid_query') : FALSE;
|
||||
}
|
||||
|
||||
// Build the query string
|
||||
$sql = 'BEGIN '.$package.'.'.$procedure.'(';
|
||||
|
||||
$have_cursor = FALSE;
|
||||
foreach ($params as $param)
|
||||
{
|
||||
$sql .= $param['name'].',';
|
||||
|
||||
if (isset($param['type']) && $param['type'] === OCI_B_CURSOR)
|
||||
{
|
||||
$have_cursor = TRUE;
|
||||
}
|
||||
}
|
||||
$sql = trim($sql, ',').'); END;';
|
||||
|
||||
$this->_reset_stmt_id = FALSE;
|
||||
$this->stmt_id = oci_parse($this->conn_id, $sql);
|
||||
$this->_bind_params($params);
|
||||
$result = $this->query($sql, FALSE, $have_cursor);
|
||||
$this->_reset_stmt_id = TRUE;
|
||||
return $result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Bind parameters
|
||||
*
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
protected function _bind_params($params)
|
||||
{
|
||||
if ( ! is_array($params) OR ! is_resource($this->stmt_id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($params as $param)
|
||||
{
|
||||
foreach (array('name', 'value', 'type', 'length') as $val)
|
||||
{
|
||||
if ( ! isset($param[$val]))
|
||||
{
|
||||
$param[$val] = '';
|
||||
}
|
||||
}
|
||||
|
||||
oci_bind_by_name($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);
|
||||
}
|
||||
return $this->result_id;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -426,7 +340,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
||||
*/
|
||||
public function affected_rows()
|
||||
{
|
||||
return oci_num_rows($this->stmt_id);
|
||||
return $this->_affected_rows;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -559,18 +473,15 @@ class CI_DB_oci8_driver extends CI_DB {
|
||||
*/
|
||||
public function error()
|
||||
{
|
||||
if ( ! empty($this->_error))
|
||||
{
|
||||
return $this->_error;
|
||||
}
|
||||
|
||||
// oci_error() returns an array that already contains
|
||||
// 'code' and 'message' keys, but it can return false
|
||||
// if there was no error ....
|
||||
if (is_resource($this->curs_id))
|
||||
{
|
||||
$error = oci_error($this->curs_id);
|
||||
}
|
||||
elseif (is_resource($this->stmt_id))
|
||||
{
|
||||
$error = oci_error($this->stmt_id);
|
||||
}
|
||||
elseif (is_resource($this->conn_id))
|
||||
if (is_resource($this->conn_id))
|
||||
{
|
||||
$error = oci_error($this->conn_id);
|
||||
}
|
||||
@@ -682,6 +593,11 @@ class CI_DB_oci8_driver extends CI_DB {
|
||||
*/
|
||||
protected function _close()
|
||||
{
|
||||
if (is_resource($this->result_id))
|
||||
{
|
||||
oci_free_statement($this->result_id);
|
||||
}
|
||||
|
||||
oci_close($this->conn_id);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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.4.1
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_oci8_forge extends CI_DB_forge {
|
||||
|
||||
@@ -159,7 +160,29 @@ class CI_DB_oci8_forge extends CI_DB_forge {
|
||||
*/
|
||||
protected function _attr_auto_increment(&$attributes, &$field)
|
||||
{
|
||||
// Not supported - sequences and triggers must be used instead
|
||||
if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'number') !== FALSE && version_compare($this->db->version(), '12.1', '>='))
|
||||
{
|
||||
$field['auto_increment'] = ' GENERATED ALWAYS AS IDENTITY';
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Process column
|
||||
*
|
||||
* @param array $field
|
||||
* @return string
|
||||
*/
|
||||
protected function _process_column($field)
|
||||
{
|
||||
return $this->db->escape_identifiers($field['name'])
|
||||
.' '.$field['type'].$field['length']
|
||||
.$field['unsigned']
|
||||
.$field['default']
|
||||
.$field['auto_increment']
|
||||
.$field['null']
|
||||
.$field['unique'];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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.4.1
|
||||
@@ -44,24 +45,10 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_oci8_result extends CI_DB_result {
|
||||
|
||||
/**
|
||||
* Statement ID
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
public $stmt_id;
|
||||
|
||||
/**
|
||||
* Cursor ID
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
public $curs_id;
|
||||
|
||||
/**
|
||||
* Limit used flag
|
||||
*
|
||||
@@ -88,11 +75,10 @@ class CI_DB_oci8_result extends CI_DB_result {
|
||||
{
|
||||
parent::__construct($driver_object);
|
||||
|
||||
$this->stmt_id = $driver_object->stmt_id;
|
||||
$this->curs_id = $driver_object->curs_id;
|
||||
$this->result_id = $driver_object->result_id;
|
||||
$this->limit_used = $driver_object->limit_used;
|
||||
$this->commit_mode =& $driver_object->commit_mode;
|
||||
$driver_object->stmt_id = FALSE;
|
||||
$driver_object->result_id = FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -104,7 +90,7 @@ class CI_DB_oci8_result extends CI_DB_result {
|
||||
*/
|
||||
public function num_fields()
|
||||
{
|
||||
$count = oci_num_fields($this->stmt_id);
|
||||
$count = oci_num_fields($this->result_id);
|
||||
|
||||
// if we used a limit we subtract it
|
||||
return ($this->limit_used) ? $count - 1 : $count;
|
||||
@@ -124,7 +110,7 @@ class CI_DB_oci8_result extends CI_DB_result {
|
||||
$field_names = array();
|
||||
for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++)
|
||||
{
|
||||
$field_names[] = oci_field_name($this->stmt_id, $c);
|
||||
$field_names[] = oci_field_name($this->result_id, $c);
|
||||
}
|
||||
return $field_names;
|
||||
}
|
||||
@@ -144,9 +130,9 @@ class CI_DB_oci8_result extends CI_DB_result {
|
||||
for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++)
|
||||
{
|
||||
$F = new stdClass();
|
||||
$F->name = oci_field_name($this->stmt_id, $c);
|
||||
$F->type = oci_field_type($this->stmt_id, $c);
|
||||
$F->max_length = oci_field_size($this->stmt_id, $c);
|
||||
$F->name = oci_field_name($this->result_id, $c);
|
||||
$F->type = oci_field_type($this->result_id, $c);
|
||||
$F->max_length = oci_field_size($this->result_id, $c);
|
||||
|
||||
$retval[] = $F;
|
||||
}
|
||||
@@ -168,17 +154,6 @@ class CI_DB_oci8_result extends CI_DB_result {
|
||||
oci_free_statement($this->result_id);
|
||||
$this->result_id = FALSE;
|
||||
}
|
||||
|
||||
if (is_resource($this->stmt_id))
|
||||
{
|
||||
oci_free_statement($this->stmt_id);
|
||||
}
|
||||
|
||||
if (is_resource($this->curs_id))
|
||||
{
|
||||
oci_cancel($this->curs_id);
|
||||
$this->curs_id = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -192,8 +167,7 @@ class CI_DB_oci8_result extends CI_DB_result {
|
||||
*/
|
||||
protected function _fetch_assoc()
|
||||
{
|
||||
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
|
||||
return oci_fetch_assoc($id);
|
||||
return oci_fetch_assoc($this->result_id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -208,9 +182,7 @@ class CI_DB_oci8_result extends CI_DB_result {
|
||||
*/
|
||||
protected function _fetch_object($class_name = 'stdClass')
|
||||
{
|
||||
$row = ($this->curs_id)
|
||||
? oci_fetch_object($this->curs_id)
|
||||
: oci_fetch_object($this->stmt_id);
|
||||
$row = oci_fetch_object($this->result_id);
|
||||
|
||||
if ($class_name === 'stdClass' OR ! $row)
|
||||
{
|
||||
@@ -226,4 +198,18 @@ class CI_DB_oci8_result extends CI_DB_result {
|
||||
return $class_name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*
|
||||
* Attempt to free remaining statement IDs.
|
||||
*
|
||||
* @see https://github.com/bcit-ci/CodeIgniter/pull/5896
|
||||
* @return void
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->free_result();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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.4.1
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_oci8_utility extends CI_DB_utility {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_odbc_driver extends CI_DB_driver {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_odbc_result extends CI_DB_result {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,11 +30,15 @@
|
||||
* @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
|
||||
*/
|
||||
|
||||
use DebugBar\DataCollector\PDO\TraceablePDO;
|
||||
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
@@ -48,7 +52,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_driver extends CI_DB {
|
||||
|
||||
@@ -64,7 +68,9 @@ class CI_DB_pdo_driver extends CI_DB {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $options = array();
|
||||
public $options = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
);
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -126,14 +132,30 @@ class CI_DB_pdo_driver extends CI_DB {
|
||||
*/
|
||||
public function db_connect($persistent = FALSE)
|
||||
{
|
||||
global $debugbar;
|
||||
|
||||
if ($persistent === TRUE)
|
||||
{
|
||||
$this->options[PDO::ATTR_PERSISTENT] = TRUE;
|
||||
}
|
||||
|
||||
// From PHP8.0, default PDO::ATTR_ERRMODE is changed
|
||||
// from PDO::ERRMODE_SILENT to PDO::ERRMODE_EXCEPTION
|
||||
// as https://wiki.php.net/rfc/pdo_default_errmode
|
||||
if ( ! isset($this->options[PDO::ATTR_ERRMODE]))
|
||||
{
|
||||
$this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return new PDO($this->dsn, $this->username, $this->password, $this->options);
|
||||
if ($debugbar) {
|
||||
$pdo = new TraceablePDO(new PDO($this->dsn, $this->username, $this->password, $this->options));
|
||||
$debugbar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($pdo));
|
||||
return $pdo;
|
||||
} else {
|
||||
return new PDO($this->dsn, $this->username, $this->password, $this->options);
|
||||
}
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
@@ -302,7 +324,7 @@ class CI_DB_pdo_driver extends CI_DB {
|
||||
$error['code'] = isset($pdo_error[1]) ? $pdo_error[0].'/'.$pdo_error[1] : $pdo_error[0];
|
||||
if (isset($pdo_error[2]))
|
||||
{
|
||||
$error['message'] = $pdo_error[2];
|
||||
$error['message'] = $pdo_error[2];
|
||||
}
|
||||
|
||||
return $error;
|
||||
@@ -326,4 +348,17 @@ class CI_DB_pdo_driver extends CI_DB {
|
||||
return 'TRUNCATE TABLE '.$table;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Close DB Connection
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _close()
|
||||
{
|
||||
$this->result_id = FALSE;
|
||||
$this->conn_id = FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_result extends CI_DB_result {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_4d_driver extends CI_DB_pdo_driver {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_4d_forge extends CI_DB_pdo_forge {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_cubrid_driver extends CI_DB_pdo_driver {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_cubrid_forge extends CI_DB_pdo_forge {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_dblib_driver extends CI_DB_pdo_driver {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_dblib_forge extends CI_DB_pdo_forge {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_firebird_driver extends CI_DB_pdo_driver {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_firebird_forge extends CI_DB_pdo_forge {
|
||||
|
||||
@@ -126,7 +127,7 @@ class CI_DB_pdo_firebird_forge extends CI_DB_pdo_forge {
|
||||
* @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);
|
||||
@@ -169,7 +170,7 @@ class CI_DB_pdo_firebird_forge extends CI_DB_pdo_forge {
|
||||
}
|
||||
|
||||
return $sqls;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_ibm_driver extends CI_DB_pdo_driver {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_ibm_forge extends CI_DB_pdo_forge {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_informix_driver extends CI_DB_pdo_driver {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_informix_forge extends CI_DB_pdo_forge {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_mysql_driver extends CI_DB_pdo_driver {
|
||||
|
||||
@@ -142,34 +143,65 @@ class CI_DB_pdo_mysql_driver extends CI_DB_pdo_driver {
|
||||
|
||||
if ( ! empty($sql))
|
||||
{
|
||||
if (empty($this->options[PDO::MYSQL_ATTR_INIT_COMMAND]))
|
||||
if (class_exists('Pdo\\Mysql'))
|
||||
{
|
||||
$this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET SESSION sql_mode = '.$sql;
|
||||
$constant = constant('Pdo\\Mysql::ATTR_INIT_COMMAND');
|
||||
} else {
|
||||
$constant = PDO::MYSQL_ATTR_INIT_COMMAND;
|
||||
}
|
||||
|
||||
if (empty($this->options[$constant]))
|
||||
{
|
||||
$this->options[$constant] = 'SET SESSION sql_mode = '.$sql;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->options[PDO::MYSQL_ATTR_INIT_COMMAND] .= ', @@session.sql_mode = '.$sql;
|
||||
$this->options[$constant] .= ', @@session.sql_mode = '.$sql;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->compress === TRUE)
|
||||
{
|
||||
$this->options[PDO::MYSQL_ATTR_COMPRESS] = TRUE;
|
||||
if (class_exists('Pdo\\Mysql'))
|
||||
{
|
||||
$constant = constant('Pdo\\Mysql::ATTR_COMPRESS');
|
||||
} else {
|
||||
$constant = PDO::MYSQL_ATTR_COMPRESS;
|
||||
}
|
||||
|
||||
$this->options[$constant] = TRUE;
|
||||
}
|
||||
|
||||
if (is_array($this->encrypt))
|
||||
{
|
||||
$ssl = array();
|
||||
empty($this->encrypt['ssl_key']) OR $ssl[PDO::MYSQL_ATTR_SSL_KEY] = $this->encrypt['ssl_key'];
|
||||
empty($this->encrypt['ssl_cert']) OR $ssl[PDO::MYSQL_ATTR_SSL_CERT] = $this->encrypt['ssl_cert'];
|
||||
empty($this->encrypt['ssl_ca']) OR $ssl[PDO::MYSQL_ATTR_SSL_CA] = $this->encrypt['ssl_ca'];
|
||||
empty($this->encrypt['ssl_capath']) OR $ssl[PDO::MYSQL_ATTR_SSL_CAPATH] = $this->encrypt['ssl_capath'];
|
||||
empty($this->encrypt['ssl_cipher']) OR $ssl[PDO::MYSQL_ATTR_SSL_CIPHER] = $this->encrypt['ssl_cipher'];
|
||||
|
||||
if (defined('PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT') && isset($this->encrypt['ssl_verify']))
|
||||
if (class_exists('Pdo\\Mysql'))
|
||||
{
|
||||
$ssl[PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT] = $this->encrypt['ssl_verify'];
|
||||
$sslKey = constant('Pdo\\Mysql::ATTR_SSL_KEY');
|
||||
$sslCert = constant('Pdo\\Mysql::ATTR_SSL_CERT');
|
||||
$sslCA = constant('Pdo\\Mysql::ATTR_SSL_CA');
|
||||
$sslCAPath = constant('Pdo\\Mysql::ATTR_SSL_CAPATH');
|
||||
$sslCipher = constant('Pdo\\Mysql::ATTR_SSL_CIPHER');
|
||||
$verify = constant('Pdo\\Mysql::ATTR_SSL_VERIFY_SERVER_CERT');
|
||||
} else {
|
||||
$sslKey = PDO::MYSQL_ATTR_SSL_KEY;
|
||||
$sslCert = PDO::MYSQL_ATTR_SSL_CERT;
|
||||
$sslCA = PDO::MYSQL_ATTR_SSL_CA;
|
||||
$sslCAPath = PDO::MYSQL_ATTR_SSL_CAPATH;
|
||||
$sslCipher = PDO::MYSQL_ATTR_SSL_CIPHER;
|
||||
$verify = defined('PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT') ? PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT : null;
|
||||
}
|
||||
|
||||
$ssl = array();
|
||||
empty($this->encrypt['ssl_key']) OR $ssl[$sslKey] = $this->encrypt['ssl_key'];
|
||||
empty($this->encrypt['ssl_cert']) OR $ssl[$sslCert] = $this->encrypt['ssl_cert'];
|
||||
empty($this->encrypt['ssl_ca']) OR $ssl[$sslCA] = $this->encrypt['ssl_ca'];
|
||||
empty($this->encrypt['ssl_capath']) OR $ssl[$sslCAPath] = $this->encrypt['ssl_capath'];
|
||||
empty($this->encrypt['ssl_cipher']) OR $ssl[$sslCipher] = $this->encrypt['ssl_cipher'];
|
||||
|
||||
if ($verify && isset($this->encrypt['ssl_verify']))
|
||||
{
|
||||
$ssl[$verify] = $this->encrypt['ssl_verify'];
|
||||
}
|
||||
|
||||
// DO NOT use array_merge() here!
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_mysql_forge extends CI_DB_pdo_forge {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_oci_driver extends CI_DB_pdo_driver {
|
||||
|
||||
@@ -142,9 +143,9 @@ class CI_DB_pdo_oci_driver extends CI_DB_pdo_driver {
|
||||
}
|
||||
|
||||
$version_string = parent::version();
|
||||
if (preg_match('#Release\s(?<version>\d+(?:\.\d+)+)#', $version_string, $match))
|
||||
if (preg_match('#(Release\s)?(?<version>\d+(?:\.\d+)+)#', $version_string, $match))
|
||||
{
|
||||
return $this->data_cache['version'] = $match[1];
|
||||
return $this->data_cache['version'] = $match['version'];
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_oci_forge extends CI_DB_pdo_forge {
|
||||
|
||||
@@ -150,9 +151,33 @@ class CI_DB_pdo_oci_forge extends CI_DB_pdo_forge {
|
||||
*/
|
||||
protected function _attr_auto_increment(&$attributes, &$field)
|
||||
{
|
||||
// Not supported - sequences and triggers must be used instead
|
||||
if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'number') !== FALSE && version_compare($this->db->version(), '12.1', '>='))
|
||||
{
|
||||
$field['auto_increment'] = ' GENERATED ALWAYS AS IDENTITY';
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Process column
|
||||
*
|
||||
* @param array $field
|
||||
* @return string
|
||||
*/
|
||||
protected function _process_column($field)
|
||||
{
|
||||
return $this->db->escape_identifiers($field['name'])
|
||||
.' '.$field['type'].$field['length']
|
||||
.$field['unsigned']
|
||||
.$field['default']
|
||||
.$field['auto_increment']
|
||||
.$field['null']
|
||||
.$field['unique'];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field attribute TYPE
|
||||
*
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_odbc_driver extends CI_DB_pdo_driver {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
|
||||
|
||||
@@ -255,7 +256,7 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
|
||||
{
|
||||
return 'SELECT "column_name"
|
||||
FROM "information_schema"."columns"
|
||||
WHERE LOWER("table_name") = '.$this->escape(strtolower($table));
|
||||
WHERE "table_schema" = \''.$this->schema.'\' AND LOWER("table_name") = '.$this->escape(strtolower($table));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -270,7 +271,7 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
|
||||
{
|
||||
$sql = 'SELECT "column_name", "data_type", "character_maximum_length", "numeric_precision", "column_default"
|
||||
FROM "information_schema"."columns"
|
||||
WHERE LOWER("table_name") = '.$this->escape(strtolower($table));
|
||||
WHERE "table_schema" = \''.$this->schema.'\' AND LOWER("table_name") = '.$this->escape(strtolower($table));
|
||||
|
||||
if (($query = $this->query($sql)) === FALSE)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge {
|
||||
|
||||
@@ -53,6 +54,13 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge {
|
||||
*/
|
||||
protected $_drop_table_if = 'DROP TABLE IF EXISTS';
|
||||
|
||||
/**
|
||||
* CREATE TABLE IF statement
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_create_table_if = 'CREATE TABLE IF NOT EXISTS';
|
||||
|
||||
/**
|
||||
* UNSIGNED support
|
||||
*
|
||||
@@ -91,7 +99,7 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge {
|
||||
|
||||
if (version_compare($this->db->version(), '9.0', '>'))
|
||||
{
|
||||
$this->create_table_if = 'CREATE TABLE IF NOT EXISTS';
|
||||
$this->_create_table_if = 'CREATE TABLE IF NOT EXISTS';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +114,7 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge {
|
||||
* @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);
|
||||
@@ -154,7 +162,7 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge {
|
||||
}
|
||||
|
||||
return $sqls;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_sqlite_driver extends CI_DB_pdo_driver {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_sqlite_forge extends CI_DB_pdo_forge {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_sqlsrv_driver extends CI_DB_pdo_driver {
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -42,7 +43,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_pdo_sqlsrv_forge extends CI_DB_pdo_forge {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -48,7 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_postgre_driver extends CI_DB {
|
||||
|
||||
@@ -78,22 +79,12 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
* Build DSN
|
||||
*
|
||||
* Creates a DSN string to be used for db_connect() and db_pconnect()
|
||||
*
|
||||
* @param array $params
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($params)
|
||||
protected function _build_dsn()
|
||||
{
|
||||
parent::__construct($params);
|
||||
|
||||
if ( ! empty($this->dsn))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dsn === '' OR $this->dsn = '';
|
||||
|
||||
if (strpos($this->hostname, '/') !== FALSE)
|
||||
@@ -104,7 +95,7 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
|
||||
$this->hostname === '' OR $this->dsn = 'host='.$this->hostname.' ';
|
||||
|
||||
if ( ! empty($this->port) && ctype_digit($this->port))
|
||||
if ( ! empty($this->port) && ctype_digit((string) $this->port))
|
||||
{
|
||||
$this->dsn .= 'port='.$this->port.' ';
|
||||
}
|
||||
@@ -145,10 +136,11 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
* Database connection
|
||||
*
|
||||
* @param bool $persistent
|
||||
* @return resource
|
||||
* @return resource|object
|
||||
*/
|
||||
public function db_connect($persistent = FALSE)
|
||||
{
|
||||
empty($this->dsn) && $this->_build_dsn();
|
||||
$this->conn_id = ($persistent === TRUE)
|
||||
? pg_pconnect($this->dsn)
|
||||
: pg_connect($this->dsn);
|
||||
@@ -163,6 +155,13 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (pg_set_client_encoding($this->conn_id, $this->char_set) !== 0)
|
||||
{
|
||||
log_message('error', "Database: Unable to set the configured connection charset ('{$this->char_set}').");
|
||||
pg_close($this->conn_id);
|
||||
return ($this->db->db_debug) ? $this->display_error('db_unable_to_set_charset', $this->char_set) : FALSE;
|
||||
}
|
||||
|
||||
empty($this->schema) OR $this->simple_query('SET search_path TO '.$this->schema.',public');
|
||||
}
|
||||
|
||||
@@ -189,19 +188,6 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set client character set
|
||||
*
|
||||
* @param string $charset
|
||||
* @return bool
|
||||
*/
|
||||
protected function _db_set_charset($charset)
|
||||
{
|
||||
return (pg_set_client_encoding($this->conn_id, $charset) === 0);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Database version number
|
||||
*
|
||||
@@ -235,7 +221,7 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
* Execute the query
|
||||
*
|
||||
* @param string $sql an SQL query
|
||||
* @return resource
|
||||
* @return resource|object
|
||||
*/
|
||||
protected function _execute($sql)
|
||||
{
|
||||
@@ -321,7 +307,7 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
*/
|
||||
public function escape($str)
|
||||
{
|
||||
if (is_php('5.4.4') && (is_string($str) OR (is_object($str) && method_exists($str, '__toString'))))
|
||||
if (is_string($str) OR (is_object($str) && method_exists($str, '__toString')))
|
||||
{
|
||||
return pg_escape_literal($this->conn_id, $str);
|
||||
}
|
||||
@@ -428,7 +414,7 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
{
|
||||
return 'SELECT "column_name"
|
||||
FROM "information_schema"."columns"
|
||||
WHERE LOWER("table_name") = '.$this->escape(strtolower($table));
|
||||
WHERE "table_schema" = \''.$this->schema.'\' AND LOWER("table_name") = '.$this->escape(strtolower($table));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -443,7 +429,7 @@ class CI_DB_postgre_driver extends CI_DB {
|
||||
{
|
||||
$sql = 'SELECT "column_name", "data_type", "character_maximum_length", "numeric_precision", "column_default"
|
||||
FROM "information_schema"."columns"
|
||||
WHERE LOWER("table_name") = '.$this->escape(strtolower($table));
|
||||
WHERE "table_schema" = \''.$this->schema.'\' AND LOWER("table_name") = '.$this->escape(strtolower($table));
|
||||
|
||||
if (($query = $this->query($sql)) === FALSE)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_postgre_forge extends CI_DB_forge {
|
||||
|
||||
@@ -86,7 +87,7 @@ class CI_DB_postgre_forge extends CI_DB_forge {
|
||||
|
||||
if (version_compare($this->db->version(), '9.0', '>'))
|
||||
{
|
||||
$this->create_table_if = 'CREATE TABLE IF NOT EXISTS';
|
||||
$this->_create_table_if = 'CREATE TABLE IF NOT EXISTS';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +102,7 @@ class CI_DB_postgre_forge extends CI_DB_forge {
|
||||
* @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);
|
||||
@@ -149,7 +150,7 @@ class CI_DB_postgre_forge extends CI_DB_forge {
|
||||
}
|
||||
|
||||
return $sqls;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Drivers
|
||||
* @category Database
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/database/
|
||||
* @link https://codeigniter.com/userguide3/database/
|
||||
*/
|
||||
class CI_DB_postgre_result extends CI_DB_result {
|
||||
|
||||
@@ -126,7 +127,7 @@ class CI_DB_postgre_result extends CI_DB_result {
|
||||
*/
|
||||
public function free_result()
|
||||
{
|
||||
if (is_resource($this->result_id))
|
||||
if ($this->result_id !== FALSE)
|
||||
{
|
||||
pg_free_result($this->result_id);
|
||||
$this->result_id = FALSE;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user