Update CodeIgniter version and associated config
This commit is contained in:
parent
ca959b0367
commit
b96a69f592
@ -3,10 +3,8 @@ language: php
|
|||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.4
|
|
||||||
- 5.5
|
|
||||||
- 5.6
|
|
||||||
- 7.0
|
- 7.0
|
||||||
|
- 7.1
|
||||||
- hhvm
|
- hhvm
|
||||||
|
|
||||||
install:
|
install:
|
||||||
|
@ -106,6 +106,27 @@ $config['enable_hooks'] = TRUE;
|
|||||||
*/
|
*/
|
||||||
$config['subclass_prefix'] = 'MY_';
|
$config['subclass_prefix'] = 'MY_';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Composer auto-loading
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Enabling this setting will tell CodeIgniter to look for a Composer
|
||||||
|
| package auto-loader script in application/vendor/autoload.php.
|
||||||
|
|
|
||||||
|
| $config['composer_autoload'] = TRUE;
|
||||||
|
|
|
||||||
|
| Or if you have your vendor/ directory located somewhere else, you
|
||||||
|
| can opt to set a specific path as well:
|
||||||
|
|
|
||||||
|
| $config['composer_autoload'] = '/path/to/vendor/autoload.php';
|
||||||
|
|
|
||||||
|
| For more information about Composer, please visit http://getcomposer.org/
|
||||||
|
|
|
||||||
|
| Note: This will NOT disable or override the CodeIgniter-specific
|
||||||
|
| autoloading (application/config/autoload.php)
|
||||||
|
*/
|
||||||
|
$config['composer_autoload'] = FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@ -149,11 +170,25 @@ $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
|
|||||||
| use segment based URLs.
|
| use segment based URLs.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
$config['allow_get_array'] = TRUE;
|
|
||||||
$config['enable_query_strings'] = FALSE;
|
$config['enable_query_strings'] = FALSE;
|
||||||
$config['controller_trigger'] = 'c';
|
$config['controller_trigger'] = 'c';
|
||||||
$config['function_trigger'] = 'm';
|
$config['function_trigger'] = 'm';
|
||||||
$config['directory_trigger'] = 'd'; // experimental not currently in use
|
$config['directory_trigger'] = 'd';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Allow $_GET array
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| By default CodeIgniter enables access to the $_GET array. If for some
|
||||||
|
| reason you would like to disable it, set 'allow_get_array' to FALSE.
|
||||||
|
|
|
||||||
|
| WARNING: This feature is DEPRECATED and currently available only
|
||||||
|
| for backwards compatibility purposes!
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
$config['allow_get_array'] = TRUE;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@ -188,6 +223,33 @@ $config['log_threshold'] = 1;
|
|||||||
*/
|
*/
|
||||||
$config['log_path'] = '';
|
$config['log_path'] = '';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Log File Extension
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The default filename extension for log files. The default 'php' allows for
|
||||||
|
| protecting the log files via basic scripting, when they are to be stored
|
||||||
|
| under a publicly accessible directory.
|
||||||
|
|
|
||||||
|
| Note: Leaving it blank will default to 'php'.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
$config['log_file_extension'] = '';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Log File Permissions
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| The file system permissions to be applied on newly created log files.
|
||||||
|
|
|
||||||
|
| IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
|
||||||
|
| integer notation (i.e. 0700, 0644, etc.)
|
||||||
|
*/
|
||||||
|
$config['log_file_permissions'] = 0644;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Date Format for Logs
|
| Date Format for Logs
|
||||||
@ -199,6 +261,17 @@ $config['log_path'] = '';
|
|||||||
*/
|
*/
|
||||||
$config['log_date_format'] = 'Y-m-d H:i:s';
|
$config['log_date_format'] = 'Y-m-d H:i:s';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Error Views Directory Path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Leave this BLANK unless you would like to set something other than the default
|
||||||
|
| application/views/errors/ directory. Use a full server path with trailing slash.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
$config['error_views_path'] = '';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Cache Directory Path
|
| Cache Directory Path
|
||||||
@ -210,6 +283,24 @@ $config['log_date_format'] = 'Y-m-d H:i:s';
|
|||||||
*/
|
*/
|
||||||
$config['cache_path'] = '';
|
$config['cache_path'] = '';
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Cache Include Query String
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Whether to take the URL query string into consideration when generating
|
||||||
|
| output cache files. Valid options are:
|
||||||
|
|
|
||||||
|
| FALSE = Disabled
|
||||||
|
| TRUE = Enabled, take all query parameters into account.
|
||||||
|
| Please be aware that this may result in numerous cache
|
||||||
|
| files generated for the same page over and over again.
|
||||||
|
| array('q') = Enabled, but only take into account the specified list
|
||||||
|
| of query parameters.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
$config['cache_query_string'] = FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Encryption Key
|
| Encryption Key
|
||||||
@ -226,21 +317,59 @@ $config['encryption_key'] = "xLx45kOkywjdvvVMxLov";
|
|||||||
| Session Variables
|
| Session Variables
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
| 'session_cookie_name' = the name you want for the cookie
|
| 'sess_driver'
|
||||||
| 'encrypt_sess_cookie' = TRUE/FALSE (boolean). Whether to encrypt the cookie
|
|
|
||||||
| 'session_expiration' = the number of SECONDS you want the session to last.
|
| The storage driver to use: files, database, redis, memcached
|
||||||
| by default sessions last 7200 seconds (two hours). Set to zero for no expiration.
|
|
|
||||||
| 'time_to_update' = how many seconds between CI refreshing Session Information
|
| 'sess_cookie_name'
|
||||||
|
|
|
||||||
|
| The session cookie name, must contain only [0-9a-z_-] characters
|
||||||
|
|
|
||||||
|
| 'sess_expiration'
|
||||||
|
|
|
||||||
|
| The number of SECONDS you want the session to last.
|
||||||
|
| Setting to 0 (zero) means expire when the browser is closed.
|
||||||
|
|
|
||||||
|
| 'sess_save_path'
|
||||||
|
|
|
||||||
|
| The location to save sessions to, driver dependent.
|
||||||
|
|
|
||||||
|
| For the 'files' driver, it's a path to a writable directory.
|
||||||
|
| WARNING: Only absolute paths are supported!
|
||||||
|
|
|
||||||
|
| For the 'database' driver, it's a table name.
|
||||||
|
| Please read up the manual for the format with other session drivers.
|
||||||
|
|
|
||||||
|
| IMPORTANT: You are REQUIRED to set a valid save path!
|
||||||
|
|
|
||||||
|
| 'sess_match_ip'
|
||||||
|
|
|
||||||
|
| Whether to match the user's IP address when reading the session data.
|
||||||
|
|
|
||||||
|
| WARNING: If you're using the database driver, don't forget to update
|
||||||
|
| your session table's PRIMARY KEY when changing this setting.
|
||||||
|
|
|
||||||
|
| 'sess_time_to_update'
|
||||||
|
|
|
||||||
|
| How many seconds between CI regenerating the session ID.
|
||||||
|
|
|
||||||
|
| 'sess_regenerate_destroy'
|
||||||
|
|
|
||||||
|
| Whether to destroy session data associated with the old session ID
|
||||||
|
| when auto-regenerating the session ID. When set to FALSE, the data
|
||||||
|
| will be later deleted by the garbage collector.
|
||||||
|
|
|
||||||
|
| Other session cookie settings are shared with the rest of the application,
|
||||||
|
| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
$config['sess_cookie_name'] = 'sess';
|
$config['sess_driver'] = 'database';
|
||||||
$config['sess_expiration'] = 43200; //12 hours
|
$config['sess_cookie_name'] = 'sess';
|
||||||
$config['sess_encrypt_cookie'] = FALSE;
|
$config['sess_expiration'] = 43200; //12 hours
|
||||||
$config['sess_use_database'] = TRUE;
|
$config['sess_save_path'] = 'ci_sessions';
|
||||||
$config['sess_table_name'] = 'ci_sessions';
|
$config['sess_match_ip'] = FALSE;
|
||||||
$config['sess_match_ip'] = TRUE;
|
$config['sess_time_to_update'] = 300;
|
||||||
$config['sess_match_useragent'] = TRUE;
|
$config['sess_regenerate_destroy'] = FALSE;
|
||||||
$config['sess_time_to_update'] = 300;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@ -280,11 +409,15 @@ $config['global_xss_filtering'] = FALSE;
|
|||||||
| 'csrf_token_name' = The token name
|
| 'csrf_token_name' = The token name
|
||||||
| 'csrf_cookie_name' = The cookie name
|
| 'csrf_cookie_name' = The cookie name
|
||||||
| 'csrf_expire' = The number in seconds the token should expire.
|
| 'csrf_expire' = The number in seconds the token should expire.
|
||||||
|
| 'csrf_regenerate' = Regenerate token on every submission
|
||||||
|
| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks
|
||||||
*/
|
*/
|
||||||
$config['csrf_protection'] = TRUE;
|
$config['csrf_protection'] = FALSE;
|
||||||
$config['csrf_token_name'] = 'csrf_token';
|
$config['csrf_token_name'] = 'csrf_token';
|
||||||
$config['csrf_cookie_name'] = 'csrf_cookie';
|
$config['csrf_cookie_name'] = 'csrf_cookie';
|
||||||
$config['csrf_expire'] = 7200;
|
$config['csrf_expire'] = 7200;
|
||||||
|
$config['csrf_regenerate'] = TRUE;
|
||||||
|
$config['csrf_exclude_uris'] = array();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
@ -296,13 +429,17 @@ $config['csrf_expire'] = 7200;
|
|||||||
| Even if it does, however, not all browsers support compression
|
| Even if it does, however, not all browsers support compression
|
||||||
| so enable only if you are reasonably sure your visitors can handle it.
|
| so enable only if you are reasonably sure your visitors can handle it.
|
||||||
|
|
|
|
||||||
|
| Only used if zlib.output_compression is turned off in your php.ini.
|
||||||
|
| Please do not use it together with httpd-level output compression.
|
||||||
|
|
|
||||||
| VERY IMPORTANT: If you are getting a blank page when compression is enabled it
|
| VERY IMPORTANT: If you are getting a blank page when compression is enabled it
|
||||||
| means you are prematurely outputting something to your browser. It could
|
| means you are prematurely outputting something to your browser. It could
|
||||||
| even be a line of whitespace at the end of one of your scripts. For
|
| even be a line of whitespace at the end of one of your scripts. For
|
||||||
| compression to work, nothing can be sent before the output buffer is called
|
| compression to work, nothing can be sent before the output buffer is called
|
||||||
| by the output class. Do not "echo" any values with compression enabled.
|
| by the output class. Do not 'echo' any values with compression enabled.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['compress_output'] = TRUE;
|
$config['compress_output'] = TRUE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,41 +1,79 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
| -------------------------------------------------------------------
|
| -------------------------------------------------------------------
|
||||||
| DATABASE CONNECTIVITY SETTINGS
|
| DATABASE CONNECTIVITY SETTINGS
|
||||||
| -------------------------------------------------------------------
|
| -------------------------------------------------------------------
|
||||||
| This file will contain the settings needed to access your database.
|
| This file will contain the settings needed to access your database.
|
||||||
|
|
|
|
||||||
| For complete instructions please consult the "Database Connection"
|
| For complete instructions please consult the 'Database Connection'
|
||||||
| page of the User Guide.
|
| page of the User Guide.
|
||||||
|
|
|
|
||||||
| -------------------------------------------------------------------
|
| -------------------------------------------------------------------
|
||||||
| EXPLANATION OF VARIABLES
|
| EXPLANATION OF VARIABLES
|
||||||
| -------------------------------------------------------------------
|
| -------------------------------------------------------------------
|
||||||
|
|
|
|
||||||
|
| ['dsn'] The full DSN string describe a connection to the database.
|
||||||
| ['hostname'] The hostname of your database server.
|
| ['hostname'] The hostname of your database server.
|
||||||
| ['username'] The username used to connect to the database
|
| ['username'] The username used to connect to the database
|
||||||
| ['password'] The password used to connect to the database
|
| ['password'] The password used to connect to the database
|
||||||
| ['database'] The name of the database you want to connect to
|
| ['database'] The name of the database you want to connect to
|
||||||
| ['dbdriver'] The database type. ie: mysql. Currently supported:
|
| ['dbdriver'] The database driver. e.g.: mysqli.
|
||||||
mysql, mysqli, postgre, odbc, mssql, sqlite, oci8
|
| Currently supported:
|
||||||
|
| cubrid, ibase, mssql, mysql, mysqli, oci8,
|
||||||
|
| odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
|
||||||
| ['dbprefix'] You can add an optional prefix, which will be added
|
| ['dbprefix'] You can add an optional prefix, which will be added
|
||||||
| to the table name when using the Active Record class
|
| to the table name when using the Query Builder class
|
||||||
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
|
| ['pconnect'] TRUE/FALSE - Whether to use a persistent connection
|
||||||
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
|
| ['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
|
||||||
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
|
| ['cache_on'] TRUE/FALSE - Enables/disables query caching
|
||||||
| ['cachedir'] The path to the folder where cache files should be stored
|
| ['cachedir'] The path to the folder where cache files should be stored
|
||||||
| ['char_set'] The character set used in communicating with the database
|
| ['char_set'] The character set used in communicating with the database
|
||||||
| ['dbcollat'] The character collation used in communicating with the database
|
| ['dbcollat'] The character collation used in communicating with the database
|
||||||
|
| NOTE: For MySQL and MySQLi databases, this setting is only used
|
||||||
|
| as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
|
||||||
|
| (and in table creation queries made with DB Forge).
|
||||||
|
| There is an incompatibility in PHP with mysql_real_escape_string() which
|
||||||
|
| can make your site vulnerable to SQL injection if you are using a
|
||||||
|
| multi-byte character set and are running versions lower than these.
|
||||||
|
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
|
||||||
|
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
|
||||||
|
| ['encrypt'] Whether or not to use an encrypted connection.
|
||||||
|
|
|
||||||
|
| 'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
|
||||||
|
| 'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
|
||||||
|
|
|
||||||
|
| 'ssl_key' - Path to the private key file
|
||||||
|
| 'ssl_cert' - Path to the public key certificate file
|
||||||
|
| 'ssl_ca' - Path to the certificate authority file
|
||||||
|
| 'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format
|
||||||
|
| 'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
|
||||||
|
| 'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not
|
||||||
|
|
|
||||||
|
| ['compress'] Whether or not to use client compression (MySQL only)
|
||||||
|
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
|
||||||
|
| - good for ensuring strict SQL while developing
|
||||||
|
| ['ssl_options'] Used to set various SSL options that can be used when making SSL connections.
|
||||||
|
| ['failover'] array - A array with 0 or more data for connections if the main should fail.
|
||||||
|
| ['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
|
||||||
|
| NOTE: Disabling this will also effectively disable both
|
||||||
|
| $this->db->last_query() and profiling of DB queries.
|
||||||
|
| When you run a query, with this setting set to TRUE (default),
|
||||||
|
| CodeIgniter will store the SQL statement for debugging purposes.
|
||||||
|
| However, this may cause high memory usage, especially if you run
|
||||||
|
| a lot of SQL queries ... disable this to avoid that problem.
|
||||||
|
|
|
|
||||||
| The $active_group variable lets you choose which connection group to
|
| The $active_group variable lets you choose which connection group to
|
||||||
| make active. By mysql there is only one group (the "mysql" group).
|
| make active. By default there is only one group (the 'default' group).
|
||||||
|
|
|
|
||||||
| The $active_record variables lets you determine whether or not to load
|
| The $query_builder variables lets you determine whether or not to load
|
||||||
| the active record class
|
| the query builder class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
$active_group = "todo";
|
$active_group = "todo";
|
||||||
$active_record = TRUE;
|
$query_builder = TRUE;
|
||||||
|
|
||||||
$db = [
|
$db = [
|
||||||
'todo' => [
|
'todo' => [
|
||||||
@ -45,7 +83,7 @@ $db = [
|
|||||||
'database' => 'todo',
|
'database' => 'todo',
|
||||||
'dbdriver' => 'postgre',
|
'dbdriver' => 'postgre',
|
||||||
'dbprefix' => 'todo_',
|
'dbprefix' => 'todo_',
|
||||||
'pconnect' => TRUE,
|
'pconnect' => FALSE,
|
||||||
'db_debug' => TRUE,
|
'db_debug' => TRUE,
|
||||||
'cache_on' => FALSE,
|
'cache_on' => FALSE,
|
||||||
'cachedir' => '',
|
'cachedir' => '',
|
||||||
@ -53,7 +91,8 @@ $db = [
|
|||||||
'dbcollat' => 'utf8_general_ci',
|
'dbcollat' => 'utf8_general_ci',
|
||||||
'swap_pre' => '',
|
'swap_pre' => '',
|
||||||
'autoinit' => TRUE,
|
'autoinit' => TRUE,
|
||||||
'stricton' => FALSE
|
'stricton' => TRUE,
|
||||||
|
'save_queries' => TRUE,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
64
application/views/errors/html/error_404.php
Normal file
64
application/views/errors/html/error_404.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
?><!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>404 Page Not Found</title>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
::selection { background-color: #E13300; color: white; }
|
||||||
|
::-moz-selection { background-color: #E13300; color: white; }
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #fff;
|
||||||
|
margin: 40px;
|
||||||
|
font: 13px/20px normal Helvetica, Arial, sans-serif;
|
||||||
|
color: #4F5155;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #003399;
|
||||||
|
background-color: transparent;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: #444;
|
||||||
|
background-color: transparent;
|
||||||
|
border-bottom: 1px solid #D0D0D0;
|
||||||
|
font-size: 19px;
|
||||||
|
font-weight: normal;
|
||||||
|
margin: 0 0 14px 0;
|
||||||
|
padding: 14px 15px 10px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-family: Consolas, Monaco, Courier New, Courier, monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
border: 1px solid #D0D0D0;
|
||||||
|
color: #002166;
|
||||||
|
display: block;
|
||||||
|
margin: 14px 0 14px 0;
|
||||||
|
padding: 12px 10px 12px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#container {
|
||||||
|
margin: 10px;
|
||||||
|
border: 1px solid #D0D0D0;
|
||||||
|
box-shadow: 0 0 8px #D0D0D0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 12px 15px 12px 15px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="container">
|
||||||
|
<h1><?php echo $heading; ?></h1>
|
||||||
|
<?php echo $message; ?>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
64
application/views/errors/html/error_db.php
Normal file
64
application/views/errors/html/error_db.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
?><!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Database Error</title>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
::selection { background-color: #E13300; color: white; }
|
||||||
|
::-moz-selection { background-color: #E13300; color: white; }
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #fff;
|
||||||
|
margin: 40px;
|
||||||
|
font: 13px/20px normal Helvetica, Arial, sans-serif;
|
||||||
|
color: #4F5155;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #003399;
|
||||||
|
background-color: transparent;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: #444;
|
||||||
|
background-color: transparent;
|
||||||
|
border-bottom: 1px solid #D0D0D0;
|
||||||
|
font-size: 19px;
|
||||||
|
font-weight: normal;
|
||||||
|
margin: 0 0 14px 0;
|
||||||
|
padding: 14px 15px 10px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-family: Consolas, Monaco, Courier New, Courier, monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
border: 1px solid #D0D0D0;
|
||||||
|
color: #002166;
|
||||||
|
display: block;
|
||||||
|
margin: 14px 0 14px 0;
|
||||||
|
padding: 12px 10px 12px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#container {
|
||||||
|
margin: 10px;
|
||||||
|
border: 1px solid #D0D0D0;
|
||||||
|
box-shadow: 0 0 8px #D0D0D0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 12px 15px 12px 15px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="container">
|
||||||
|
<h1><?php echo $heading; ?></h1>
|
||||||
|
<?php echo $message; ?>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
32
application/views/errors/html/error_exception.php
Normal file
32
application/views/errors/html/error_exception.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
|
||||||
|
|
||||||
|
<h4>An uncaught Exception was encountered</h4>
|
||||||
|
|
||||||
|
<p>Type: <?php echo get_class($exception); ?></p>
|
||||||
|
<p>Message: <?php echo $message; ?></p>
|
||||||
|
<p>Filename: <?php echo $exception->getFile(); ?></p>
|
||||||
|
<p>Line Number: <?php echo $exception->getLine(); ?></p>
|
||||||
|
|
||||||
|
<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === TRUE): ?>
|
||||||
|
|
||||||
|
<p>Backtrace:</p>
|
||||||
|
<?php foreach ($exception->getTrace() as $error): ?>
|
||||||
|
|
||||||
|
<?php if (isset($error['file']) && strpos($error['file'], realpath(BASEPATH)) !== 0): ?>
|
||||||
|
|
||||||
|
<p style="margin-left:10px">
|
||||||
|
File: <?php echo $error['file']; ?><br />
|
||||||
|
Line: <?php echo $error['line']; ?><br />
|
||||||
|
Function: <?php echo $error['function']; ?>
|
||||||
|
</p>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php endforeach ?>
|
||||||
|
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
</div>
|
64
application/views/errors/html/error_general.php
Normal file
64
application/views/errors/html/error_general.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
?><!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Error</title>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
::selection { background-color: #E13300; color: white; }
|
||||||
|
::-moz-selection { background-color: #E13300; color: white; }
|
||||||
|
|
||||||
|
body {
|
||||||
|
background-color: #fff;
|
||||||
|
margin: 40px;
|
||||||
|
font: 13px/20px normal Helvetica, Arial, sans-serif;
|
||||||
|
color: #4F5155;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #003399;
|
||||||
|
background-color: transparent;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: #444;
|
||||||
|
background-color: transparent;
|
||||||
|
border-bottom: 1px solid #D0D0D0;
|
||||||
|
font-size: 19px;
|
||||||
|
font-weight: normal;
|
||||||
|
margin: 0 0 14px 0;
|
||||||
|
padding: 14px 15px 10px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-family: Consolas, Monaco, Courier New, Courier, monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
border: 1px solid #D0D0D0;
|
||||||
|
color: #002166;
|
||||||
|
display: block;
|
||||||
|
margin: 14px 0 14px 0;
|
||||||
|
padding: 12px 10px 12px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#container {
|
||||||
|
margin: 10px;
|
||||||
|
border: 1px solid #D0D0D0;
|
||||||
|
box-shadow: 0 0 8px #D0D0D0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 12px 15px 12px 15px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="container">
|
||||||
|
<h1><?php echo $heading; ?></h1>
|
||||||
|
<?php echo $message; ?>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
33
application/views/errors/html/error_php.php
Normal file
33
application/views/errors/html/error_php.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
|
||||||
|
|
||||||
|
<h4>A PHP Error was encountered</h4>
|
||||||
|
|
||||||
|
<p>Severity: <?php echo $severity; ?></p>
|
||||||
|
<p>Message: <?php echo $message; ?></p>
|
||||||
|
<p>Filename: <?php echo $filepath; ?></p>
|
||||||
|
<p>Line Number: <?php echo $line; ?></p>
|
||||||
|
|
||||||
|
<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === TRUE): ?>
|
||||||
|
|
||||||
|
<p>Backtrace:</p>
|
||||||
|
<?php foreach (debug_backtrace() as $error): ?>
|
||||||
|
|
||||||
|
<?php if (isset($error['file']) && strpos($error['file'], realpath(BASEPATH)) !== 0): ?>
|
||||||
|
|
||||||
|
<p style="margin-left:10px">
|
||||||
|
File: <?php echo $error['file'] ?><br />
|
||||||
|
Line: <?php echo $error['line'] ?><br />
|
||||||
|
Function: <?php echo $error['function'] ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php endforeach ?>
|
||||||
|
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
</div>
|
@ -18,7 +18,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<p>If it sounds interesting, or useful, sign up and try it out.</p>
|
<p>If it sounds interesting, or useful, sign up and try it out.</p>
|
||||||
<p><strong>Want to try it without creating an account? Login with username: <em>guest</em> and password: <em>guest</em></strong></p>
|
<p><strong>Want to try it without creating an account? Login with username: <em>guest</em> and password: <em>guest</em></strong></p>
|
||||||
<p>It's nice to have feedback. Send suggestions/comments/criticism to <a href="mailto:tim@timshomepage.net?subject=Tim's Todo Feedback">tim (at) timshomepage.net</a> or <a href="http://twitter.com/timw4mail">@timw4mail</a> on Twitter.</p>
|
<p>It's nice to have feedback. Send suggestions/comments/criticism to <a href="mailto:tim@timshomepage.net?subject=Tim's Todo Feedback">tim (at) timshomepage.net</a>.</p>
|
||||||
</section>
|
</section>
|
||||||
<section class="right">
|
<section class="right">
|
||||||
<?= form_open('login') ?>
|
<?= form_open('login') ?>
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
<?= $this->pagination->create_links(); ?>
|
<?= $this->pagination->create_links(); ?>
|
||||||
</section>
|
</section>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php elseif(count($task_list) < 1): ?>
|
<?php elseif(empty($task_list)): ?>
|
||||||
<h1><?= $list_type ?> Tasks</h1>
|
<h1><?= $list_type ?> Tasks</h1>
|
||||||
<p>You currently have no <?= $list_type ?> tasks.</p>
|
<p>You currently have no <?= $list_type ?> tasks.</p>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"role": "Developer"
|
"role": "Developer"
|
||||||
}],
|
}],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.4",
|
"php": ">=7.0",
|
||||||
"robmorgan/phinx": "*",
|
"robmorgan/phinx": "*",
|
||||||
"ircmaxell/password-compat": "1.0.*"
|
"ircmaxell/password-compat": "1.0.*"
|
||||||
}
|
}
|
||||||
|
49
migrations/20190220154203_recreate_session_db_table.php
Normal file
49
migrations/20190220154203_recreate_session_db_table.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Phinx\Migration\AbstractMigration;
|
||||||
|
|
||||||
|
class RecreateSessionDbTable extends AbstractMigration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Change Method.
|
||||||
|
*
|
||||||
|
* More information on this method is available here:
|
||||||
|
* http://docs.phinx.org/en/latest/migrations.html#the-change-method
|
||||||
|
*
|
||||||
|
* Uncomment this method if you would like to use it.
|
||||||
|
*/
|
||||||
|
public function change()
|
||||||
|
{
|
||||||
|
// Session storage table
|
||||||
|
if ($this->hasTable('todo_ci_sessions'))
|
||||||
|
{
|
||||||
|
$this->table('todo_ci_sessions')->drop();
|
||||||
|
|
||||||
|
$this->table('todo_ci_sessions', [
|
||||||
|
'id' => FALSE,
|
||||||
|
'primary_key' => 'id'
|
||||||
|
])->addColumn('id' , 'string', ['limit' => 128, 'null' => FALSE])
|
||||||
|
->addColumn('ip_address', 'string', ['limit' => 45, 'null' => FALSE])
|
||||||
|
->addColumn('timestamp', 'integer', ['default' => 0, 'null' => FALSE])
|
||||||
|
->addColumn('data', 'text', ['default' => '', 'null' => FALSE])
|
||||||
|
->create();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrate Up.
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrate Down.
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
33
phinx.yml
Normal file
33
phinx.yml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
paths:
|
||||||
|
migrations: %%PHINX_CONFIG_DIR%%/migrations
|
||||||
|
|
||||||
|
environments:
|
||||||
|
default_migration_table: phinxlog
|
||||||
|
default_database: development
|
||||||
|
|
||||||
|
development:
|
||||||
|
adapter: pgsql
|
||||||
|
host: localhost
|
||||||
|
name: todo
|
||||||
|
user: todo
|
||||||
|
pass: todo
|
||||||
|
port: 5432
|
||||||
|
charset: utf8
|
||||||
|
|
||||||
|
testing:
|
||||||
|
adapter: pgsql
|
||||||
|
host: localhost
|
||||||
|
name: todo_test
|
||||||
|
user: todo_test
|
||||||
|
pass: test
|
||||||
|
port: 5432
|
||||||
|
charset: utf8
|
||||||
|
|
||||||
|
node:
|
||||||
|
adapter: mysql
|
||||||
|
host: localhost
|
||||||
|
name: node
|
||||||
|
user: node
|
||||||
|
pass: node
|
||||||
|
port: 3306
|
||||||
|
charset: utf8
|
7
system/.htaccess
Executable file → Normal file
7
system/.htaccess
Executable file → Normal file
@ -1 +1,6 @@
|
|||||||
Deny from all
|
<IfModule authz_core_module>
|
||||||
|
Require all denied
|
||||||
|
</IfModule>
|
||||||
|
<IfModule !authz_core_module>
|
||||||
|
Deny from all
|
||||||
|
</IfModule>
|
105
system/core/Benchmark.php
Executable file → Normal file
105
system/core/Benchmark.php
Executable file → Normal file
@ -1,61 +1,82 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php
|
||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.1.6 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* This content is released under the MIT License (MIT)
|
||||||
* @author ExpressionEngine Dev Team
|
*
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc.
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
* @license http://codeigniter.com/user_guide/license.html
|
*
|
||||||
* @link http://codeigniter.com
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* @since Version 1.0
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CodeIgniter Benchmark Class
|
* Benchmark Class
|
||||||
*
|
*
|
||||||
* This class enables you to mark points and calculate the time difference
|
* This class enables you to mark points and calculate the time difference
|
||||||
* between them. Memory consumption can also be displayed.
|
* between them. Memory consumption can also be displayed.
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* @package CodeIgniter
|
||||||
* @subpackage Libraries
|
* @subpackage Libraries
|
||||||
* @category Libraries
|
* @category Libraries
|
||||||
* @author ExpressionEngine Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/libraries/benchmark.html
|
* @link https://codeigniter.com/user_guide/libraries/benchmark.html
|
||||||
*/
|
*/
|
||||||
class CI_Benchmark {
|
class CI_Benchmark {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of all benchmark markers and when they were added
|
* List of all benchmark markers
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $marker = array();
|
public $marker = array();
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a benchmark marker
|
* Set a benchmark marker
|
||||||
*
|
*
|
||||||
* Multiple calls to this function can be made so that several
|
* Multiple calls to this function can be made so that several
|
||||||
* execution points can be timed
|
* execution points can be timed.
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $name Marker name
|
||||||
* @param string $name name of the marker
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function mark($name)
|
public function mark($name)
|
||||||
{
|
{
|
||||||
$this->marker[$name] = microtime();
|
$this->marker[$name] = microtime(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Elapsed time
|
||||||
|
*
|
||||||
* Calculates the time difference between two marked points.
|
* Calculates the time difference between two marked points.
|
||||||
*
|
*
|
||||||
* If the first parameter is empty this function instead returns the
|
* If the first parameter is empty this function instead returns the
|
||||||
@ -63,15 +84,17 @@ class CI_Benchmark {
|
|||||||
* execution time to be shown in a template. The output class will
|
* execution time to be shown in a template. The output class will
|
||||||
* swap the real value for this variable.
|
* swap the real value for this variable.
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $point1 A particular marked point
|
||||||
* @param string a particular marked point
|
* @param string $point2 A particular marked point
|
||||||
* @param string a particular marked point
|
* @param int $decimals Number of decimal places
|
||||||
* @param integer the number of decimal places
|
*
|
||||||
* @return mixed
|
* @return string Calculated elapsed time on success,
|
||||||
|
* an '{elapsed_string}' if $point1 is empty
|
||||||
|
* or an empty string if $point1 is not found.
|
||||||
*/
|
*/
|
||||||
function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
|
public function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
|
||||||
{
|
{
|
||||||
if ($point1 == '')
|
if ($point1 === '')
|
||||||
{
|
{
|
||||||
return '{elapsed_time}';
|
return '{elapsed_time}';
|
||||||
}
|
}
|
||||||
@ -83,13 +106,10 @@ class CI_Benchmark {
|
|||||||
|
|
||||||
if ( ! isset($this->marker[$point2]))
|
if ( ! isset($this->marker[$point2]))
|
||||||
{
|
{
|
||||||
$this->marker[$point2] = microtime();
|
$this->marker[$point2] = microtime(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
list($sm, $ss) = explode(' ', $this->marker[$point1]);
|
return number_format($this->marker[$point2] - $this->marker[$point1], $decimals);
|
||||||
list($em, $es) = explode(' ', $this->marker[$point2]);
|
|
||||||
|
|
||||||
return number_format(($em + $es) - ($sm + $ss), $decimals);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -97,22 +117,17 @@ class CI_Benchmark {
|
|||||||
/**
|
/**
|
||||||
* Memory Usage
|
* Memory Usage
|
||||||
*
|
*
|
||||||
* This function returns the {memory_usage} pseudo-variable.
|
* Simply returns the {memory_usage} marker.
|
||||||
|
*
|
||||||
* This permits it to be put it anywhere in a template
|
* This permits it to be put it anywhere in a template
|
||||||
* without the memory being calculated until the end.
|
* without the memory being calculated until the end.
|
||||||
* The output class will swap the real value for this variable.
|
* The output class will swap the real value for this variable.
|
||||||
*
|
*
|
||||||
* @access public
|
* @return string '{memory_usage}'
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
function memory_usage()
|
public function memory_usage()
|
||||||
{
|
{
|
||||||
return '{memory_usage}';
|
return '{memory_usage}';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// END CI_Benchmark class
|
|
||||||
|
|
||||||
/* End of file Benchmark.php */
|
|
||||||
/* Location: ./system/core/Benchmark.php */
|
|
483
system/core/CodeIgniter.php
Executable file → Normal file
483
system/core/CodeIgniter.php
Executable file → Normal file
@ -1,19 +1,41 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php
|
||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.1.6 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* This content is released under the MIT License (MIT)
|
||||||
* @author ExpressionEngine Dev Team
|
*
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc.
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
* @license http://codeigniter.com/user_guide/license.html
|
*
|
||||||
* @link http://codeigniter.com
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* @since Version 1.0
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* System Initialization File
|
* System Initialization File
|
||||||
@ -21,60 +43,101 @@
|
|||||||
* Loads the base classes and executes the request.
|
* Loads the base classes and executes the request.
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* @package CodeIgniter
|
||||||
* @subpackage codeigniter
|
* @subpackage CodeIgniter
|
||||||
* @category Front-controller
|
* @category Front-controller
|
||||||
* @author ExpressionEngine Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/
|
* @link https://codeigniter.com/user_guide/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CodeIgniter Version
|
* CodeIgniter Version
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define('CI_VERSION', '2.2.0');
|
const CI_VERSION = '3.1.10';
|
||||||
|
|
||||||
/**
|
|
||||||
* CodeIgniter Branch (Core = TRUE, Reactor = FALSE)
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
define('CI_CORE', FALSE);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ------------------------------------------------------
|
|
||||||
* Load the global functions
|
|
||||||
* ------------------------------------------------------
|
|
||||||
*/
|
|
||||||
require(BASEPATH.'core/Common.php');
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
* Load the framework constants
|
* Load the framework constants
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
|
if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
|
||||||
{
|
{
|
||||||
require(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
|
require_once(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (file_exists(APPPATH.'config/constants.php'))
|
||||||
{
|
{
|
||||||
require(APPPATH.'config/constants.php');
|
require_once(APPPATH.'config/constants.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ------------------------------------------------------
|
||||||
|
* Load the global functions
|
||||||
|
* ------------------------------------------------------
|
||||||
|
*/
|
||||||
|
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
|
* Define a custom error handler so we can log PHP errors
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
set_error_handler('_exception_handler');
|
set_error_handler('_error_handler');
|
||||||
|
set_exception_handler('_exception_handler');
|
||||||
if ( ! is_php('5.3'))
|
register_shutdown_function('_shutdown_handler');
|
||||||
{
|
|
||||||
@set_magic_quotes_runtime(0); // Kill magic quotes
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
@ -85,26 +148,39 @@
|
|||||||
* The subclass prefix allows CI to know if a core class is
|
* The subclass prefix allows CI to know if a core class is
|
||||||
* being extended via a library in the local application
|
* being extended via a library in the local application
|
||||||
* "libraries" folder. Since CI allows config items to be
|
* "libraries" folder. Since CI allows config items to be
|
||||||
* overriden via data set in the main index. php file,
|
* overridden via data set in the main index.php file,
|
||||||
* before proceeding we need to know if a subclass_prefix
|
* before proceeding we need to know if a subclass_prefix
|
||||||
* override exists. If so, we will set this value now,
|
* override exists. If so, we will set this value now,
|
||||||
* before any classes are loaded
|
* before any classes are loaded
|
||||||
* Note: Since the config file data is cached it doesn't
|
* Note: Since the config file data is cached it doesn't
|
||||||
* hurt to load it here.
|
* hurt to load it here.
|
||||||
*/
|
*/
|
||||||
if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '')
|
if ( ! empty($assign_to_config['subclass_prefix']))
|
||||||
{
|
{
|
||||||
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
|
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
* Set a liberal script execution time limit
|
* Should we use a Composer autoloader?
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
|
if ($composer_autoload = config_item('composer_autoload'))
|
||||||
{
|
{
|
||||||
@set_time_limit(300);
|
if ($composer_autoload === TRUE)
|
||||||
|
{
|
||||||
|
file_exists(APPPATH.'vendor/autoload.php')
|
||||||
|
? require_once(APPPATH.'vendor/autoload.php')
|
||||||
|
: log_message('error', '$config[\'composer_autoload\'] is set to TRUE but '.APPPATH.'vendor/autoload.php was not found.');
|
||||||
|
}
|
||||||
|
elseif (file_exists($composer_autoload))
|
||||||
|
{
|
||||||
|
require_once($composer_autoload);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_message('error', 'Could not find the specified $config[\'composer_autoload\'] path: '.$composer_autoload);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -128,33 +204,96 @@
|
|||||||
* Is there a "pre_system" hook?
|
* Is there a "pre_system" hook?
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
$EXT->_call_hook('pre_system');
|
$EXT->call_hook('pre_system');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
* Instantiate the config class
|
* Instantiate the config class
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Note: It is important that Config is loaded first as
|
||||||
|
* most other classes depend on it either directly or by
|
||||||
|
* depending on another class that uses it.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
$CFG =& load_class('Config', 'core');
|
$CFG =& load_class('Config', 'core');
|
||||||
|
|
||||||
// Do we have any manually set config items in the index.php file?
|
// Do we have any manually set config items in the index.php file?
|
||||||
if (isset($assign_to_config))
|
if (isset($assign_to_config) && is_array($assign_to_config))
|
||||||
{
|
{
|
||||||
$CFG->_assign_to_config($assign_to_config);
|
foreach ($assign_to_config as $key => $value)
|
||||||
|
{
|
||||||
|
$CFG->set_item($key, $value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ------------------------------------------------------
|
||||||
|
* Important charset-related stuff
|
||||||
|
* ------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Configure mbstring and/or iconv if they are enabled
|
||||||
|
* and set MB_ENABLED and ICONV_ENABLED constants, so
|
||||||
|
* that we don't repeatedly do extension_loaded() or
|
||||||
|
* function_exists() calls.
|
||||||
|
*
|
||||||
|
* Note: UTF-8 class depends on this. It used to be done
|
||||||
|
* in it's constructor, but it's _not_ class-specific.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$charset = strtoupper(config_item('charset'));
|
||||||
|
ini_set('default_charset', $charset);
|
||||||
|
|
||||||
|
if (extension_loaded('mbstring'))
|
||||||
|
{
|
||||||
|
define('MB_ENABLED', TRUE);
|
||||||
|
// mbstring.internal_encoding is deprecated starting with PHP 5.6
|
||||||
|
// and it's usage triggers E_DEPRECATED messages.
|
||||||
|
@ini_set('mbstring.internal_encoding', $charset);
|
||||||
|
// This is required for mb_convert_encoding() to strip invalid characters.
|
||||||
|
// That's utilized by CI_Utf8, but it's also done for consistency with iconv.
|
||||||
|
mb_substitute_character('none');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
define('MB_ENABLED', FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
// There's an ICONV_IMPL constant, but the PHP manual says that using
|
||||||
|
// iconv's predefined constants is "strongly discouraged".
|
||||||
|
if (extension_loaded('iconv'))
|
||||||
|
{
|
||||||
|
define('ICONV_ENABLED', TRUE);
|
||||||
|
// iconv.internal_encoding is deprecated starting with PHP 5.6
|
||||||
|
// and it's usage triggers E_DEPRECATED messages.
|
||||||
|
@ini_set('iconv.internal_encoding', $charset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
define('ICONV_ENABLED', FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_php('5.6'))
|
||||||
|
{
|
||||||
|
ini_set('php.internal_encoding', $charset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ------------------------------------------------------
|
||||||
|
* Load compatibility features
|
||||||
|
* ------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once(BASEPATH.'core/compat/mbstring.php');
|
||||||
|
require_once(BASEPATH.'core/compat/hash.php');
|
||||||
|
require_once(BASEPATH.'core/compat/password.php');
|
||||||
|
require_once(BASEPATH.'core/compat/standard.php');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
* Instantiate the UTF-8 class
|
* Instantiate the UTF-8 class
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*
|
|
||||||
* Note: Order here is rather important as the UTF-8
|
|
||||||
* class needs to be used very early on, but it cannot
|
|
||||||
* properly determine if UTf-8 can be supported until
|
|
||||||
* after the Config class is instantiated.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$UNI =& load_class('Utf8', 'core');
|
$UNI =& load_class('Utf8', 'core');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -169,14 +308,7 @@
|
|||||||
* Instantiate the routing class and set the routing
|
* Instantiate the routing class and set the routing
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
$RTR =& load_class('Router', 'core');
|
$RTR =& load_class('Router', 'core', isset($routing) ? $routing : NULL);
|
||||||
$RTR->_set_routing();
|
|
||||||
|
|
||||||
// Set any routing overrides that may exist in the main index file
|
|
||||||
if (isset($routing))
|
|
||||||
{
|
|
||||||
$RTR->_set_overrides($routing);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
@ -187,15 +319,12 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
* Is there a valid cache file? If so, we're done...
|
* Is there a valid cache file? If so, we're done...
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if ($EXT->_call_hook('cache_override') === FALSE)
|
if ($EXT->call_hook('cache_override') === FALSE && $OUT->_display_cache($CFG, $URI) === TRUE)
|
||||||
{
|
{
|
||||||
if ($OUT->_display_cache($CFG, $URI) == TRUE)
|
exit;
|
||||||
{
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -226,76 +355,157 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
// Load the base controller class
|
// Load the base controller class
|
||||||
require BASEPATH.'core/Controller.php';
|
require_once BASEPATH.'core/Controller.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to the CI_Controller method.
|
||||||
|
*
|
||||||
|
* Returns current CI instance object
|
||||||
|
*
|
||||||
|
* @return CI_Controller
|
||||||
|
*/
|
||||||
function &get_instance()
|
function &get_instance()
|
||||||
{
|
{
|
||||||
return CI_Controller::get_instance();
|
return CI_Controller::get_instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
|
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
|
||||||
{
|
{
|
||||||
require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
|
require_once APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the local application controller
|
|
||||||
// Note: The Router class automatically validates the controller path using the router->_validate_request().
|
|
||||||
// If this include fails it means that the default controller in the Routes.php file is not resolving to something valid.
|
|
||||||
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'))
|
|
||||||
{
|
|
||||||
show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
|
|
||||||
}
|
|
||||||
|
|
||||||
include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php');
|
|
||||||
|
|
||||||
// Set a mark point for benchmarking
|
// Set a mark point for benchmarking
|
||||||
$BM->mark('loading_time:_base_classes_end');
|
$BM->mark('loading_time:_base_classes_end');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
* Security check
|
* Sanity checks
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*
|
*
|
||||||
* None of the functions in the app controller or the
|
* The Router class has already validated the request,
|
||||||
* loader class can be called via the URI, nor can
|
* leaving us with 3 options here:
|
||||||
* controller functions that begin with an underscore
|
*
|
||||||
|
* 1) an empty class name, if we reached the default
|
||||||
|
* controller, but it didn't exist;
|
||||||
|
* 2) a query string which doesn't go through a
|
||||||
|
* file_exists() check
|
||||||
|
* 3) a regular request for a non-existing page
|
||||||
|
*
|
||||||
|
* We handle all of these as a 404 error.
|
||||||
|
*
|
||||||
|
* Furthermore, none of the methods in the app controller
|
||||||
|
* or the loader class can be called via the URI, nor can
|
||||||
|
* controller methods that begin with an underscore.
|
||||||
*/
|
*/
|
||||||
$class = $RTR->fetch_class();
|
|
||||||
$method = $RTR->fetch_method();
|
|
||||||
|
|
||||||
if ( ! class_exists($class)
|
$e404 = FALSE;
|
||||||
OR strncmp($method, '_', 1) == 0
|
$class = ucfirst($RTR->class);
|
||||||
OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller')))
|
$method = $RTR->method;
|
||||||
)
|
|
||||||
|
if (empty($class) OR ! file_exists(APPPATH.'controllers/'.$RTR->directory.$class.'.php'))
|
||||||
|
{
|
||||||
|
$e404 = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
require_once(APPPATH.'controllers/'.$RTR->directory.$class.'.php');
|
||||||
|
|
||||||
|
if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method))
|
||||||
|
{
|
||||||
|
$e404 = TRUE;
|
||||||
|
}
|
||||||
|
elseif (method_exists($class, '_remap'))
|
||||||
|
{
|
||||||
|
$params = array($method, array_slice($URI->rsegments, 2));
|
||||||
|
$method = '_remap';
|
||||||
|
}
|
||||||
|
elseif ( ! method_exists($class, $method))
|
||||||
|
{
|
||||||
|
$e404 = TRUE;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* DO NOT CHANGE THIS, NOTHING ELSE WORKS!
|
||||||
|
*
|
||||||
|
* - method_exists() returns true for non-public methods, which passes the previous elseif
|
||||||
|
* - is_callable() returns false for PHP 4-style constructors, even if there's a __construct()
|
||||||
|
* - method_exists($class, '__construct') won't work because CI_Controller::__construct() is inherited
|
||||||
|
* - People will only complain if this doesn't work, even though it is documented that it shouldn't.
|
||||||
|
*
|
||||||
|
* ReflectionMethod::isConstructor() is the ONLY reliable check,
|
||||||
|
* knowing which method will be executed as a constructor.
|
||||||
|
*/
|
||||||
|
elseif ( ! is_callable(array($class, $method)))
|
||||||
|
{
|
||||||
|
$reflection = new ReflectionMethod($class, $method);
|
||||||
|
if ( ! $reflection->isPublic() OR $reflection->isConstructor())
|
||||||
|
{
|
||||||
|
$e404 = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($e404)
|
||||||
{
|
{
|
||||||
if ( ! empty($RTR->routes['404_override']))
|
if ( ! empty($RTR->routes['404_override']))
|
||||||
{
|
{
|
||||||
$x = explode('/', $RTR->routes['404_override']);
|
if (sscanf($RTR->routes['404_override'], '%[^/]/%s', $error_class, $error_method) !== 2)
|
||||||
$class = $x[0];
|
|
||||||
$method = (isset($x[1]) ? $x[1] : 'index');
|
|
||||||
if ( ! class_exists($class))
|
|
||||||
{
|
{
|
||||||
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
|
$error_method = 'index';
|
||||||
{
|
|
||||||
show_404("{$class}/{$method}");
|
|
||||||
}
|
|
||||||
|
|
||||||
include_once(APPPATH.'controllers/'.$class.'.php');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$error_class = ucfirst($error_class);
|
||||||
|
|
||||||
|
if ( ! class_exists($error_class, FALSE))
|
||||||
|
{
|
||||||
|
if (file_exists(APPPATH.'controllers/'.$RTR->directory.$error_class.'.php'))
|
||||||
|
{
|
||||||
|
require_once(APPPATH.'controllers/'.$RTR->directory.$error_class.'.php');
|
||||||
|
$e404 = ! class_exists($error_class, FALSE);
|
||||||
|
}
|
||||||
|
// Were we in a directory? If so, check for a global override
|
||||||
|
elseif ( ! empty($RTR->directory) && file_exists(APPPATH.'controllers/'.$error_class.'.php'))
|
||||||
|
{
|
||||||
|
require_once(APPPATH.'controllers/'.$error_class.'.php');
|
||||||
|
if (($e404 = ! class_exists($error_class, FALSE)) === FALSE)
|
||||||
|
{
|
||||||
|
$RTR->directory = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$e404 = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Did we reset the $e404 flag? If so, set the rsegments, starting from index 1
|
||||||
|
if ( ! $e404)
|
||||||
|
{
|
||||||
|
$class = $error_class;
|
||||||
|
$method = $error_method;
|
||||||
|
|
||||||
|
$URI->rsegments = array(
|
||||||
|
1 => $class,
|
||||||
|
2 => $method
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
show_404("{$class}/{$method}");
|
show_404($RTR->directory.$class.'/'.$method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($method !== '_remap')
|
||||||
|
{
|
||||||
|
$params = array_slice($URI->rsegments, 2);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
* Is there a "pre_controller" hook?
|
* Is there a "pre_controller" hook?
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
$EXT->_call_hook('pre_controller');
|
$EXT->call_hook('pre_controller');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
@ -312,53 +522,14 @@
|
|||||||
* Is there a "post_controller_constructor" hook?
|
* Is there a "post_controller_constructor" hook?
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
$EXT->_call_hook('post_controller_constructor');
|
$EXT->call_hook('post_controller_constructor');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
* Call the requested method
|
* Call the requested method
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
// Is there a "remap" function? If so, we call it instead
|
call_user_func_array(array(&$CI, $method), $params);
|
||||||
if (method_exists($CI, '_remap'))
|
|
||||||
{
|
|
||||||
$CI->_remap($method, array_slice($URI->rsegments, 2));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// is_callable() returns TRUE on some versions of PHP 5 for private and protected
|
|
||||||
// methods, so we'll use this workaround for consistent behavior
|
|
||||||
if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))
|
|
||||||
{
|
|
||||||
// Check and see if we are using a 404 override and use it.
|
|
||||||
if ( ! empty($RTR->routes['404_override']))
|
|
||||||
{
|
|
||||||
$x = explode('/', $RTR->routes['404_override']);
|
|
||||||
$class = $x[0];
|
|
||||||
$method = (isset($x[1]) ? $x[1] : 'index');
|
|
||||||
if ( ! class_exists($class))
|
|
||||||
{
|
|
||||||
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
|
|
||||||
{
|
|
||||||
show_404("{$class}/{$method}");
|
|
||||||
}
|
|
||||||
|
|
||||||
include_once(APPPATH.'controllers/'.$class.'.php');
|
|
||||||
unset($CI);
|
|
||||||
$CI = new $class();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
show_404("{$class}/{$method}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call the requested method.
|
|
||||||
// Any URI segments present (besides the class/function) will be passed to the method for convenience
|
|
||||||
call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Mark a benchmark end point
|
// Mark a benchmark end point
|
||||||
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
|
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
|
||||||
@ -368,14 +539,14 @@
|
|||||||
* Is there a "post_controller" hook?
|
* Is there a "post_controller" hook?
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
$EXT->_call_hook('post_controller');
|
$EXT->call_hook('post_controller');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
* Send the final rendered output to the browser
|
* Send the final rendered output to the browser
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
if ($EXT->_call_hook('display_override') === FALSE)
|
if ($EXT->call_hook('display_override') === FALSE)
|
||||||
{
|
{
|
||||||
$OUT->_display();
|
$OUT->_display();
|
||||||
}
|
}
|
||||||
@ -385,18 +556,4 @@
|
|||||||
* Is there a "post_system" hook?
|
* Is there a "post_system" hook?
|
||||||
* ------------------------------------------------------
|
* ------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
$EXT->_call_hook('post_system');
|
$EXT->call_hook('post_system');
|
||||||
|
|
||||||
/*
|
|
||||||
* ------------------------------------------------------
|
|
||||||
* Close the DB connection if one exists
|
|
||||||
* ------------------------------------------------------
|
|
||||||
*/
|
|
||||||
if (class_exists('CI_DB') AND isset($CI->db))
|
|
||||||
{
|
|
||||||
$CI->db->close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* End of file CodeIgniter.php */
|
|
||||||
/* Location: ./system/core/CodeIgniter.php */
|
|
||||||
|
907
system/core/Common.php
Executable file → Normal file
907
system/core/Common.php
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
410
system/core/Config.php
Executable file → Normal file
410
system/core/Config.php
Executable file → Normal file
@ -1,78 +1,107 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php
|
||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.1.6 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* This content is released under the MIT License (MIT)
|
||||||
* @author ExpressionEngine Dev Team
|
*
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc.
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
* @license http://codeigniter.com/user_guide/license.html
|
*
|
||||||
* @link http://codeigniter.com
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* @since Version 1.0
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CodeIgniter Config Class
|
* Config Class
|
||||||
*
|
*
|
||||||
* This class contains functions that enable config files to be managed
|
* This class contains functions that enable config files to be managed
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* @package CodeIgniter
|
||||||
* @subpackage Libraries
|
* @subpackage Libraries
|
||||||
* @category Libraries
|
* @category Libraries
|
||||||
* @author ExpressionEngine Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/libraries/config.html
|
* @link https://codeigniter.com/user_guide/libraries/config.html
|
||||||
*/
|
*/
|
||||||
class CI_Config {
|
class CI_Config {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of all loaded config values
|
* List of all loaded config values
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $config = array();
|
public $config = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of all loaded config files
|
* List of all loaded config files
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $is_loaded = array();
|
public $is_loaded = array();
|
||||||
/**
|
|
||||||
* List of paths to search when trying to load a config file
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
var $_config_paths = array(APPPATH);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* List of paths to search when trying to load a config file.
|
||||||
*
|
*
|
||||||
* Sets the $config data from the primary config.php file as a class variable
|
* @used-by CI_Loader
|
||||||
*
|
* @var array
|
||||||
* @access public
|
|
||||||
* @param string the config file name
|
|
||||||
* @param boolean if configuration values should be loaded into their own section
|
|
||||||
* @param boolean true if errors should just return false, false if an error message should be displayed
|
|
||||||
* @return boolean if the file was successfully loaded or not
|
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public $_config_paths = array(APPPATH);
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor
|
||||||
|
*
|
||||||
|
* Sets the $config data from the primary config.php file as a class variable.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->config = get_config();
|
$this->config =& get_config();
|
||||||
log_message('debug', "Config Class Initialized");
|
|
||||||
|
|
||||||
// Set the base_url automatically if none was provided
|
// Set the base_url automatically if none was provided
|
||||||
if ($this->config['base_url'] == '')
|
if (empty($this->config['base_url']))
|
||||||
{
|
{
|
||||||
if (isset($_SERVER['HTTP_HOST']))
|
if (isset($_SERVER['SERVER_ADDR']))
|
||||||
{
|
{
|
||||||
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
|
if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE)
|
||||||
$base_url .= '://'. $_SERVER['HTTP_HOST'];
|
{
|
||||||
$base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
|
$server_addr = '['.$_SERVER['SERVER_ADDR'].']';
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$server_addr = $_SERVER['SERVER_ADDR'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$base_url = (is_https() ? 'https' : 'http').'://'.$server_addr
|
||||||
|
.substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$base_url = 'http://localhost/';
|
$base_url = 'http://localhost/';
|
||||||
@ -80,6 +109,8 @@ class CI_Config {
|
|||||||
|
|
||||||
$this->set_item('base_url', $base_url);
|
$this->set_item('base_url', $base_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_message('info', 'Config Class Initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -87,91 +118,71 @@ class CI_Config {
|
|||||||
/**
|
/**
|
||||||
* Load Config File
|
* Load Config File
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $file Configuration file name
|
||||||
* @param string the config file name
|
* @param bool $use_sections Whether configuration values should be loaded into their own section
|
||||||
* @param boolean if configuration values should be loaded into their own section
|
* @param bool $fail_gracefully Whether to just return FALSE or display an error message
|
||||||
* @param boolean true if errors should just return false, false if an error message should be displayed
|
* @return bool TRUE if the file was loaded correctly or FALSE on failure
|
||||||
* @return boolean if the file was loaded correctly
|
|
||||||
*/
|
*/
|
||||||
function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
|
public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
|
||||||
{
|
{
|
||||||
$file = ($file == '') ? 'config' : str_replace('.php', '', $file);
|
$file = ($file === '') ? 'config' : str_replace('.php', '', $file);
|
||||||
$found = FALSE;
|
|
||||||
$loaded = FALSE;
|
$loaded = FALSE;
|
||||||
|
|
||||||
$check_locations = defined('ENVIRONMENT')
|
|
||||||
? array(ENVIRONMENT.'/'.$file, $file)
|
|
||||||
: array($file);
|
|
||||||
|
|
||||||
foreach ($this->_config_paths as $path)
|
foreach ($this->_config_paths as $path)
|
||||||
{
|
{
|
||||||
foreach ($check_locations as $location)
|
foreach (array($file, ENVIRONMENT.DIRECTORY_SEPARATOR.$file) as $location)
|
||||||
{
|
{
|
||||||
$file_path = $path.'config/'.$location.'.php';
|
$file_path = $path.'config/'.$location.'.php';
|
||||||
|
|
||||||
if (in_array($file_path, $this->is_loaded, TRUE))
|
if (in_array($file_path, $this->is_loaded, TRUE))
|
||||||
{
|
{
|
||||||
$loaded = TRUE;
|
return TRUE;
|
||||||
continue 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($file_path))
|
if ( ! file_exists($file_path))
|
||||||
{
|
{
|
||||||
$found = TRUE;
|
continue;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($found === FALSE)
|
include($file_path);
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
include($file_path);
|
if ( ! isset($config) OR ! is_array($config))
|
||||||
|
|
||||||
if ( ! isset($config) OR ! is_array($config))
|
|
||||||
{
|
|
||||||
if ($fail_gracefully === TRUE)
|
|
||||||
{
|
{
|
||||||
return FALSE;
|
if ($fail_gracefully === TRUE)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
|
||||||
}
|
}
|
||||||
show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($use_sections === TRUE)
|
if ($use_sections === TRUE)
|
||||||
{
|
|
||||||
if (isset($this->config[$file]))
|
|
||||||
{
|
{
|
||||||
$this->config[$file] = array_merge($this->config[$file], $config);
|
$this->config[$file] = isset($this->config[$file])
|
||||||
|
? array_merge($this->config[$file], $config)
|
||||||
|
: $config;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->config[$file] = $config;
|
$this->config = array_merge($this->config, $config);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->config = array_merge($this->config, $config);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->is_loaded[] = $file_path;
|
$this->is_loaded[] = $file_path;
|
||||||
unset($config);
|
$config = NULL;
|
||||||
|
$loaded = TRUE;
|
||||||
$loaded = TRUE;
|
log_message('debug', 'Config file loaded: '.$file_path);
|
||||||
log_message('debug', 'Config file loaded: '.$file_path);
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($loaded === FALSE)
|
if ($loaded === TRUE)
|
||||||
{
|
{
|
||||||
if ($fail_gracefully === TRUE)
|
return TRUE;
|
||||||
{
|
}
|
||||||
return FALSE;
|
elseif ($fail_gracefully === TRUE)
|
||||||
}
|
{
|
||||||
show_error('The configuration file '.$file.'.php does not exist.');
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
show_error('The configuration file '.$file.'.php does not exist.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -179,59 +190,35 @@ class CI_Config {
|
|||||||
/**
|
/**
|
||||||
* Fetch a config file item
|
* Fetch a config file item
|
||||||
*
|
*
|
||||||
*
|
* @param string $item Config item name
|
||||||
* @access public
|
* @param string $index Index name
|
||||||
* @param string the config item name
|
* @return string|null The configuration item or NULL if the item doesn't exist
|
||||||
* @param string the index name
|
|
||||||
* @param bool
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
function item($item, $index = '')
|
public function item($item, $index = '')
|
||||||
{
|
{
|
||||||
if ($index == '')
|
if ($index == '')
|
||||||
{
|
{
|
||||||
if ( ! isset($this->config[$item]))
|
return isset($this->config[$item]) ? $this->config[$item] : NULL;
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$pref = $this->config[$item];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( ! isset($this->config[$index]))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! isset($this->config[$index][$item]))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$pref = $this->config[$index][$item];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $pref;
|
return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a config file item - adds slash after item (if item is not empty)
|
* Fetch a config file item with slash appended (if not empty)
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $item Config item name
|
||||||
* @param string the config item name
|
* @return string|null The configuration item or NULL if the item doesn't exist
|
||||||
* @param bool
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
function slash_item($item)
|
public function slash_item($item)
|
||||||
{
|
{
|
||||||
if ( ! isset($this->config[$item]))
|
if ( ! isset($this->config[$item]))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
if( trim($this->config[$item]) == '')
|
elseif (trim($this->config[$item]) === '')
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -243,80 +230,122 @@ class CI_Config {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Site URL
|
* Site URL
|
||||||
|
*
|
||||||
* Returns base_url . index_page [. uri_string]
|
* Returns base_url . index_page [. uri_string]
|
||||||
*
|
*
|
||||||
* @access public
|
* @uses CI_Config::_uri_string()
|
||||||
* @param string the URI string
|
*
|
||||||
|
* @param string|string[] $uri URI string or an array of segments
|
||||||
|
* @param string $protocol
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function site_url($uri = '')
|
public function site_url($uri = '', $protocol = NULL)
|
||||||
{
|
{
|
||||||
if ($uri == '')
|
$base_url = $this->slash_item('base_url');
|
||||||
|
|
||||||
|
if (isset($protocol))
|
||||||
{
|
{
|
||||||
return $this->slash_item('base_url').$this->item('index_page');
|
// For protocol-relative links
|
||||||
|
if ($protocol === '')
|
||||||
|
{
|
||||||
|
$base_url = substr($base_url, strpos($base_url, '//'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->item('enable_query_strings') == FALSE)
|
if (empty($uri))
|
||||||
{
|
{
|
||||||
$suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
|
return $base_url.$this->item('index_page');
|
||||||
return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
$uri = $this->_uri_string($uri);
|
||||||
|
|
||||||
|
if ($this->item('enable_query_strings') === FALSE)
|
||||||
{
|
{
|
||||||
return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri);
|
$suffix = isset($this->config['url_suffix']) ? $this->config['url_suffix'] : '';
|
||||||
|
|
||||||
|
if ($suffix !== '')
|
||||||
|
{
|
||||||
|
if (($offset = strpos($uri, '?')) !== FALSE)
|
||||||
|
{
|
||||||
|
$uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$uri .= $suffix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $base_url.$this->slash_item('index_page').$uri;
|
||||||
}
|
}
|
||||||
|
elseif (strpos($uri, '?') === FALSE)
|
||||||
|
{
|
||||||
|
$uri = '?'.$uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $base_url.$this->item('index_page').$uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base URL
|
* Base URL
|
||||||
|
*
|
||||||
* Returns base_url [. uri_string]
|
* Returns base_url [. uri_string]
|
||||||
*
|
*
|
||||||
* @access public
|
* @uses CI_Config::_uri_string()
|
||||||
* @param string $uri
|
*
|
||||||
* @return string
|
* @param string|string[] $uri URI string or an array of segments
|
||||||
|
* @param string $protocol
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function base_url($uri = '')
|
public function base_url($uri = '', $protocol = NULL)
|
||||||
{
|
{
|
||||||
return $this->slash_item('base_url').ltrim($this->_uri_string($uri), '/');
|
$base_url = $this->slash_item('base_url');
|
||||||
|
|
||||||
|
if (isset($protocol))
|
||||||
|
{
|
||||||
|
// For protocol-relative links
|
||||||
|
if ($protocol === '')
|
||||||
|
{
|
||||||
|
$base_url = substr($base_url, strpos($base_url, '//'));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $base_url.$this->_uri_string($uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------
|
// -------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build URI string for use in Config::site_url() and Config::base_url()
|
* Build URI string
|
||||||
*
|
*
|
||||||
* @access protected
|
* @used-by CI_Config::site_url()
|
||||||
* @param $uri
|
* @used-by CI_Config::base_url()
|
||||||
* @return string
|
*
|
||||||
|
* @param string|string[] $uri URI string or an array of segments
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function _uri_string($uri)
|
protected function _uri_string($uri)
|
||||||
{
|
{
|
||||||
if ($this->item('enable_query_strings') == FALSE)
|
if ($this->item('enable_query_strings') === FALSE)
|
||||||
{
|
{
|
||||||
if (is_array($uri))
|
is_array($uri) && $uri = implode('/', $uri);
|
||||||
{
|
return ltrim($uri, '/');
|
||||||
$uri = implode('/', $uri);
|
|
||||||
}
|
|
||||||
$uri = trim($uri, '/');
|
|
||||||
}
|
}
|
||||||
else
|
elseif (is_array($uri))
|
||||||
{
|
{
|
||||||
if (is_array($uri))
|
return http_build_query($uri);
|
||||||
{
|
|
||||||
$i = 0;
|
|
||||||
$str = '';
|
|
||||||
foreach ($uri as $key => $val)
|
|
||||||
{
|
|
||||||
$prefix = ($i == 0) ? '' : '&';
|
|
||||||
$str .= $prefix.$key.'='.$val;
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$uri = $str;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $uri;
|
|
||||||
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -324,12 +353,12 @@ class CI_Config {
|
|||||||
/**
|
/**
|
||||||
* System URL
|
* System URL
|
||||||
*
|
*
|
||||||
* @access public
|
* @deprecated 3.0.0 Encourages insecure practices
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function system_url()
|
public function system_url()
|
||||||
{
|
{
|
||||||
$x = explode("/", preg_replace("|/*(.+?)/*$|", "\\1", BASEPATH));
|
$x = explode('/', preg_replace('|/*(.+?)/*$|', '\\1', BASEPATH));
|
||||||
return $this->slash_item('base_url').end($x).'/';
|
return $this->slash_item('base_url').end($x).'/';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,42 +367,13 @@ class CI_Config {
|
|||||||
/**
|
/**
|
||||||
* Set a config file item
|
* Set a config file item
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $item Config item key
|
||||||
* @param string the config item key
|
* @param string $value Config item value
|
||||||
* @param string the config item value
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function set_item($item, $value)
|
public function set_item($item, $value)
|
||||||
{
|
{
|
||||||
$this->config[$item] = $value;
|
$this->config[$item] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Assign to Config
|
|
||||||
*
|
|
||||||
* This function is called by the front controller (CodeIgniter.php)
|
|
||||||
* after the Config class is instantiated. It permits config items
|
|
||||||
* to be assigned or overriden by variables contained in the index.php file
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @param array
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function _assign_to_config($items = array())
|
|
||||||
{
|
|
||||||
if (is_array($items))
|
|
||||||
{
|
|
||||||
foreach ($items as $key => $val)
|
|
||||||
{
|
|
||||||
$this->set_item($key, $val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// END CI_Config class
|
|
||||||
|
|
||||||
/* End of file Config.php */
|
|
||||||
/* Location: ./system/core/Config.php */
|
|
||||||
|
74
system/core/Controller.php
Executable file → Normal file
74
system/core/Controller.php
Executable file → Normal file
@ -1,22 +1,44 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php
|
||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.1.6 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* This content is released under the MIT License (MIT)
|
||||||
* @author ExpressionEngine Dev Team
|
*
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc.
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
* @license http://codeigniter.com/user_guide/license.html
|
*
|
||||||
* @link http://codeigniter.com
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* @since Version 1.0
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CodeIgniter Application Controller Class
|
* Application Controller Class
|
||||||
*
|
*
|
||||||
* This class object is the super class that every library in
|
* This class object is the super class that every library in
|
||||||
* CodeIgniter will be assigned to.
|
* CodeIgniter will be assigned to.
|
||||||
@ -24,15 +46,22 @@
|
|||||||
* @package CodeIgniter
|
* @package CodeIgniter
|
||||||
* @subpackage Libraries
|
* @subpackage Libraries
|
||||||
* @category Libraries
|
* @category Libraries
|
||||||
* @author ExpressionEngine Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/general/controllers.html
|
* @link https://codeigniter.com/user_guide/general/controllers.html
|
||||||
*/
|
*/
|
||||||
class CI_Controller {
|
class CI_Controller {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reference to the CI singleton
|
||||||
|
*
|
||||||
|
* @var object
|
||||||
|
*/
|
||||||
private static $instance;
|
private static $instance;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Class constructor
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
@ -47,18 +76,21 @@ class CI_Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->load =& load_class('Loader', 'core');
|
$this->load =& load_class('Loader', 'core');
|
||||||
|
|
||||||
$this->load->initialize();
|
$this->load->initialize();
|
||||||
|
log_message('info', 'Controller Class Initialized');
|
||||||
log_message('debug', "Controller Class Initialized");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the CI singleton
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
public static function &get_instance()
|
public static function &get_instance()
|
||||||
{
|
{
|
||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// END Controller class
|
|
||||||
|
|
||||||
/* End of file Controller.php */
|
}
|
||||||
/* Location: ./system/core/Controller.php */
|
|
||||||
|
271
system/core/Exceptions.php
Executable file → Normal file
271
system/core/Exceptions.php
Executable file → Normal file
@ -1,19 +1,41 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php
|
||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.1.6 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* This content is released under the MIT License (MIT)
|
||||||
* @author ExpressionEngine Dev Team
|
*
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc.
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
* @license http://codeigniter.com/user_guide/license.html
|
*
|
||||||
* @link http://codeigniter.com
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* @since Version 1.0
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exceptions Class
|
* Exceptions Class
|
||||||
@ -21,53 +43,47 @@
|
|||||||
* @package CodeIgniter
|
* @package CodeIgniter
|
||||||
* @subpackage Libraries
|
* @subpackage Libraries
|
||||||
* @category Exceptions
|
* @category Exceptions
|
||||||
* @author ExpressionEngine Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/libraries/exceptions.html
|
* @link https://codeigniter.com/user_guide/libraries/exceptions.html
|
||||||
*/
|
*/
|
||||||
class CI_Exceptions {
|
class CI_Exceptions {
|
||||||
var $action;
|
|
||||||
var $severity;
|
|
||||||
var $message;
|
|
||||||
var $filename;
|
|
||||||
var $line;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Nesting level of the output buffering mechanism
|
* Nesting level of the output buffering mechanism
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $ob_level;
|
public $ob_level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List if available error levels
|
* List of available error levels
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $levels = array(
|
public $levels = array(
|
||||||
E_ERROR => 'Error',
|
E_ERROR => 'Error',
|
||||||
E_WARNING => 'Warning',
|
E_WARNING => 'Warning',
|
||||||
E_PARSE => 'Parsing Error',
|
E_PARSE => 'Parsing Error',
|
||||||
E_NOTICE => 'Notice',
|
E_NOTICE => 'Notice',
|
||||||
E_CORE_ERROR => 'Core Error',
|
E_CORE_ERROR => 'Core Error',
|
||||||
E_CORE_WARNING => 'Core Warning',
|
E_CORE_WARNING => 'Core Warning',
|
||||||
E_COMPILE_ERROR => 'Compile Error',
|
E_COMPILE_ERROR => 'Compile Error',
|
||||||
E_COMPILE_WARNING => 'Compile Warning',
|
E_COMPILE_WARNING => 'Compile Warning',
|
||||||
E_USER_ERROR => 'User Error',
|
E_USER_ERROR => 'User Error',
|
||||||
E_USER_WARNING => 'User Warning',
|
E_USER_WARNING => 'User Warning',
|
||||||
E_USER_NOTICE => 'User Notice',
|
E_USER_NOTICE => 'User Notice',
|
||||||
E_STRICT => 'Runtime Notice'
|
E_STRICT => 'Runtime Notice'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Class constructor
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->ob_level = ob_get_level();
|
$this->ob_level = ob_get_level();
|
||||||
// Note: Do not log messages from this constructor.
|
// Note: Do not log messages from this constructor.
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -75,45 +91,52 @@ class CI_Exceptions {
|
|||||||
/**
|
/**
|
||||||
* Exception Logger
|
* Exception Logger
|
||||||
*
|
*
|
||||||
* This function logs PHP generated error messages
|
* Logs PHP generated error messages
|
||||||
*
|
*
|
||||||
* @access private
|
* @param int $severity Log level
|
||||||
* @param string the error severity
|
* @param string $message Error message
|
||||||
* @param string the error string
|
* @param string $filepath File path
|
||||||
* @param string the error filepath
|
* @param int $line Line number
|
||||||
* @param string the error line number
|
* @return void
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
function log_exception($severity, $message, $filepath, $line)
|
public function log_exception($severity, $message, $filepath, $line)
|
||||||
{
|
{
|
||||||
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
|
$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
|
||||||
|
log_message('error', 'Severity: '.$severity.' --> '.$message.' '.$filepath.' '.$line);
|
||||||
log_message('error', 'Severity: '.$severity.' --> '.$message. ' '.$filepath.' '.$line, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 404 Page Not Found Handler
|
* 404 Error Handler
|
||||||
*
|
*
|
||||||
* @access private
|
* @uses CI_Exceptions::show_error()
|
||||||
* @param string the page
|
*
|
||||||
* @param bool log error yes/no
|
* @param string $page Page URI
|
||||||
* @return string
|
* @param bool $log_error Whether to log the error
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function show_404($page = '', $log_error = TRUE)
|
public function show_404($page = '', $log_error = TRUE)
|
||||||
{
|
{
|
||||||
$heading = "404 Page Not Found";
|
if (is_cli())
|
||||||
$message = "The page you requested was not found.";
|
{
|
||||||
|
$heading = 'Not Found';
|
||||||
|
$message = 'The controller/method pair you requested was not found.';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$heading = '404 Page Not Found';
|
||||||
|
$message = 'The page you requested was not found.';
|
||||||
|
}
|
||||||
|
|
||||||
// By default we log this, but allow a dev to skip it
|
// By default we log this, but allow a dev to skip it
|
||||||
if ($log_error)
|
if ($log_error)
|
||||||
{
|
{
|
||||||
log_message('error', '404 Page Not Found --> '.$page);
|
log_message('error', $heading.': '.$page);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $this->show_error($heading, $message, 'error_404', 404);
|
echo $this->show_error($heading, $message, 'error_404', 404);
|
||||||
exit;
|
exit(4); // EXIT_UNKNOWN_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -121,29 +144,42 @@ class CI_Exceptions {
|
|||||||
/**
|
/**
|
||||||
* General Error Page
|
* General Error Page
|
||||||
*
|
*
|
||||||
* This function takes an error message as input
|
* Takes an error message as input (either as a string or an array)
|
||||||
* (either as a string or an array) and displays
|
* and displays it using the specified template.
|
||||||
* it using the specified template.
|
|
||||||
*
|
*
|
||||||
* @access private
|
* @param string $heading Page heading
|
||||||
* @param string the heading
|
* @param string|string[] $message Error message
|
||||||
* @param string the message
|
* @param string $template Template name
|
||||||
* @param string the template name
|
* @param int $status_code (default: 500)
|
||||||
* @param int the status code
|
*
|
||||||
* @return string
|
* @return string Error page output
|
||||||
*/
|
*/
|
||||||
function show_error($heading, $message, $template = 'error_general', $status_code = 500)
|
public function show_error($heading, $message, $template = 'error_general', $status_code = 500)
|
||||||
{
|
{
|
||||||
set_status_header($status_code);
|
$templates_path = config_item('error_views_path');
|
||||||
|
if (empty($templates_path))
|
||||||
|
{
|
||||||
|
$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
|
||||||
|
}
|
||||||
|
|
||||||
$message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';
|
if (is_cli())
|
||||||
|
{
|
||||||
|
$message = "\t".(is_array($message) ? implode("\n\t", $message) : $message);
|
||||||
|
$template = 'cli'.DIRECTORY_SEPARATOR.$template;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
set_status_header($status_code);
|
||||||
|
$message = '<p>'.(is_array($message) ? implode('</p><p>', $message) : $message).'</p>';
|
||||||
|
$template = 'html'.DIRECTORY_SEPARATOR.$template;
|
||||||
|
}
|
||||||
|
|
||||||
if (ob_get_level() > $this->ob_level + 1)
|
if (ob_get_level() > $this->ob_level + 1)
|
||||||
{
|
{
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
}
|
}
|
||||||
ob_start();
|
ob_start();
|
||||||
include(APPPATH.'errors/'.$template.'.php');
|
include($templates_path.$template.'.php');
|
||||||
$buffer = ob_get_contents();
|
$buffer = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
return $buffer;
|
return $buffer;
|
||||||
@ -151,27 +187,77 @@ class CI_Exceptions {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
public function show_exception($exception)
|
||||||
|
{
|
||||||
|
$templates_path = config_item('error_views_path');
|
||||||
|
if (empty($templates_path))
|
||||||
|
{
|
||||||
|
$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = $exception->getMessage();
|
||||||
|
if (empty($message))
|
||||||
|
{
|
||||||
|
$message = '(null)';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_cli())
|
||||||
|
{
|
||||||
|
$templates_path .= 'cli'.DIRECTORY_SEPARATOR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$templates_path .= 'html'.DIRECTORY_SEPARATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ob_get_level() > $this->ob_level + 1)
|
||||||
|
{
|
||||||
|
ob_end_flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
include($templates_path.'error_exception.php');
|
||||||
|
$buffer = ob_get_contents();
|
||||||
|
ob_end_clean();
|
||||||
|
echo $buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Native PHP error handler
|
* Native PHP error handler
|
||||||
*
|
*
|
||||||
* @access private
|
* @param int $severity Error level
|
||||||
* @param string the error severity
|
* @param string $message Error message
|
||||||
* @param string the error string
|
* @param string $filepath File path
|
||||||
* @param string the error filepath
|
* @param int $line Line number
|
||||||
* @param string the error line number
|
* @return void
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
function show_php_error($severity, $message, $filepath, $line)
|
public function show_php_error($severity, $message, $filepath, $line)
|
||||||
{
|
{
|
||||||
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
|
$templates_path = config_item('error_views_path');
|
||||||
|
if (empty($templates_path))
|
||||||
$filepath = str_replace("\\", "/", $filepath);
|
|
||||||
|
|
||||||
// For safety reasons we do not show the full file path
|
|
||||||
if (FALSE !== strpos($filepath, '/'))
|
|
||||||
{
|
{
|
||||||
$x = explode('/', $filepath);
|
$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
|
||||||
$filepath = $x[count($x)-2].'/'.end($x);
|
}
|
||||||
|
|
||||||
|
$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
|
||||||
|
|
||||||
|
// For safety reasons we don't show the full file path in non-CLI requests
|
||||||
|
if ( ! is_cli())
|
||||||
|
{
|
||||||
|
$filepath = str_replace('\\', '/', $filepath);
|
||||||
|
if (FALSE !== strpos($filepath, '/'))
|
||||||
|
{
|
||||||
|
$x = explode('/', $filepath);
|
||||||
|
$filepath = $x[count($x)-2].'/'.end($x);
|
||||||
|
}
|
||||||
|
|
||||||
|
$template = 'html'.DIRECTORY_SEPARATOR.'error_php';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$template = 'cli'.DIRECTORY_SEPARATOR.'error_php';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ob_get_level() > $this->ob_level + 1)
|
if (ob_get_level() > $this->ob_level + 1)
|
||||||
@ -179,15 +265,10 @@ class CI_Exceptions {
|
|||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
}
|
}
|
||||||
ob_start();
|
ob_start();
|
||||||
include(APPPATH.'errors/error_php.php');
|
include($templates_path.$template.'.php');
|
||||||
$buffer = ob_get_contents();
|
$buffer = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
echo $buffer;
|
echo $buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// END Exceptions Class
|
|
||||||
|
|
||||||
/* End of file Exceptions.php */
|
|
||||||
/* Location: ./system/core/Exceptions.php */
|
|
218
system/core/Hooks.php
Executable file → Normal file
218
system/core/Hooks.php
Executable file → Normal file
@ -1,95 +1,114 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php
|
||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.1.6 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* This content is released under the MIT License (MIT)
|
||||||
* @author ExpressionEngine Dev Team
|
*
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc.
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
* @license http://codeigniter.com/user_guide/license.html
|
*
|
||||||
* @link http://codeigniter.com
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* @since Version 1.0
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CodeIgniter Hooks Class
|
* Hooks Class
|
||||||
*
|
*
|
||||||
* Provides a mechanism to extend the base system without hacking.
|
* Provides a mechanism to extend the base system without hacking.
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* @package CodeIgniter
|
||||||
* @subpackage Libraries
|
* @subpackage Libraries
|
||||||
* @category Libraries
|
* @category Libraries
|
||||||
* @author ExpressionEngine Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/libraries/encryption.html
|
* @link https://codeigniter.com/user_guide/general/hooks.html
|
||||||
*/
|
*/
|
||||||
class CI_Hooks {
|
class CI_Hooks {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines wether hooks are enabled
|
* Determines whether hooks are enabled
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
var $enabled = FALSE;
|
public $enabled = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of all hooks set in config/hooks.php
|
* List of all hooks set in config/hooks.php
|
||||||
*
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $hooks = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array with class objects to use hooks methods
|
||||||
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $hooks = array();
|
protected $_objects = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines wether hook is in progress, used to prevent infinte loops
|
* In progress flag
|
||||||
*
|
*
|
||||||
* @var bool
|
* Determines whether hook is in progress, used to prevent infinte loops
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
*/
|
*/
|
||||||
var $in_progress = FALSE;
|
protected $_in_progress = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
*/
|
|
||||||
function __construct()
|
|
||||||
{
|
|
||||||
$this->_initialize();
|
|
||||||
log_message('debug', "Hooks Class Initialized");
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the Hooks Preferences
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _initialize()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$CFG =& load_class('Config', 'core');
|
$CFG =& load_class('Config', 'core');
|
||||||
|
log_message('info', 'Hooks Class Initialized');
|
||||||
|
|
||||||
// If hooks are not enabled in the config file
|
// If hooks are not enabled in the config file
|
||||||
// there is nothing else to do
|
// there is nothing else to do
|
||||||
|
if ($CFG->item('enable_hooks') === FALSE)
|
||||||
if ($CFG->item('enable_hooks') == FALSE)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the "hooks" definition file.
|
// Grab the "hooks" definition file.
|
||||||
// If there are no hooks, we're done.
|
if (file_exists(APPPATH.'config/hooks.php'))
|
||||||
|
|
||||||
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
|
|
||||||
{
|
|
||||||
include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
|
|
||||||
}
|
|
||||||
elseif (is_file(APPPATH.'config/hooks.php'))
|
|
||||||
{
|
{
|
||||||
include(APPPATH.'config/hooks.php');
|
include(APPPATH.'config/hooks.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
|
||||||
|
{
|
||||||
|
include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there are no hooks, we're done.
|
||||||
if ( ! isset($hook) OR ! is_array($hook))
|
if ( ! isset($hook) OR ! is_array($hook))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -104,20 +123,21 @@ class CI_Hooks {
|
|||||||
/**
|
/**
|
||||||
* Call Hook
|
* Call Hook
|
||||||
*
|
*
|
||||||
* Calls a particular hook
|
* Calls a particular hook. Called by CodeIgniter.php.
|
||||||
*
|
*
|
||||||
* @access private
|
* @uses CI_Hooks::_run_hook()
|
||||||
* @param string the hook name
|
*
|
||||||
* @return mixed
|
* @param string $which Hook name
|
||||||
|
* @return bool TRUE on success or FALSE on failure
|
||||||
*/
|
*/
|
||||||
function _call_hook($which = '')
|
public function call_hook($which = '')
|
||||||
{
|
{
|
||||||
if ( ! $this->enabled OR ! isset($this->hooks[$which]))
|
if ( ! $this->enabled OR ! isset($this->hooks[$which]))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0]))
|
if (is_array($this->hooks[$which]) && ! isset($this->hooks[$which]['function']))
|
||||||
{
|
{
|
||||||
foreach ($this->hooks[$which] as $val)
|
foreach ($this->hooks[$which] as $val)
|
||||||
{
|
{
|
||||||
@ -139,13 +159,21 @@ class CI_Hooks {
|
|||||||
*
|
*
|
||||||
* Runs a particular hook
|
* Runs a particular hook
|
||||||
*
|
*
|
||||||
* @access private
|
* @param array $data Hook details
|
||||||
* @param array the hook details
|
* @return bool TRUE on success or FALSE on failure
|
||||||
* @return bool
|
|
||||||
*/
|
*/
|
||||||
function _run_hook($data)
|
protected function _run_hook($data)
|
||||||
{
|
{
|
||||||
if ( ! is_array($data))
|
// Closures/lambda functions and array($object, 'method') callables
|
||||||
|
if (is_callable($data))
|
||||||
|
{
|
||||||
|
is_array($data)
|
||||||
|
? $data[0]->{$data[1]}()
|
||||||
|
: $data();
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
elseif ( ! is_array($data))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -156,8 +184,7 @@ class CI_Hooks {
|
|||||||
|
|
||||||
// If the script being called happens to have the same
|
// If the script being called happens to have the same
|
||||||
// hook call within it a loop can happen
|
// hook call within it a loop can happen
|
||||||
|
if ($this->_in_progress === TRUE)
|
||||||
if ($this->in_progress == TRUE)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -166,7 +193,7 @@ class CI_Hooks {
|
|||||||
// Set file path
|
// Set file path
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
||||||
if ( ! isset($data['filepath']) OR ! isset($data['filename']))
|
if ( ! isset($data['filepath'], $data['filename']))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -178,71 +205,62 @@ class CI_Hooks {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------
|
// Determine and class and/or function names
|
||||||
// Set class/function name
|
$class = empty($data['class']) ? FALSE : $data['class'];
|
||||||
// -----------------------------------
|
$function = empty($data['function']) ? FALSE : $data['function'];
|
||||||
|
$params = isset($data['params']) ? $data['params'] : '';
|
||||||
|
|
||||||
$class = FALSE;
|
if (empty($function))
|
||||||
$function = FALSE;
|
|
||||||
$params = '';
|
|
||||||
|
|
||||||
if (isset($data['class']) AND $data['class'] != '')
|
|
||||||
{
|
|
||||||
$class = $data['class'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($data['function']))
|
|
||||||
{
|
|
||||||
$function = $data['function'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($data['params']))
|
|
||||||
{
|
|
||||||
$params = $data['params'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($class === FALSE AND $function === FALSE)
|
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------
|
// Set the _in_progress flag
|
||||||
// Set the in_progress flag
|
$this->_in_progress = TRUE;
|
||||||
// -----------------------------------
|
|
||||||
|
|
||||||
$this->in_progress = TRUE;
|
|
||||||
|
|
||||||
// -----------------------------------
|
|
||||||
// Call the requested class and/or function
|
// Call the requested class and/or function
|
||||||
// -----------------------------------
|
|
||||||
|
|
||||||
if ($class !== FALSE)
|
if ($class !== FALSE)
|
||||||
{
|
{
|
||||||
if ( ! class_exists($class))
|
// The object is stored?
|
||||||
|
if (isset($this->_objects[$class]))
|
||||||
{
|
{
|
||||||
require($filepath);
|
if (method_exists($this->_objects[$class], $function))
|
||||||
|
{
|
||||||
|
$this->_objects[$class]->$function($params);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $this->_in_progress = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
class_exists($class, FALSE) OR require_once($filepath);
|
||||||
|
|
||||||
$HOOK = new $class;
|
if ( ! class_exists($class, FALSE) OR ! method_exists($class, $function))
|
||||||
$HOOK->$function($params);
|
{
|
||||||
|
return $this->_in_progress = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the object and execute the method
|
||||||
|
$this->_objects[$class] = new $class();
|
||||||
|
$this->_objects[$class]->$function($params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
function_exists($function) OR require_once($filepath);
|
||||||
|
|
||||||
if ( ! function_exists($function))
|
if ( ! function_exists($function))
|
||||||
{
|
{
|
||||||
require($filepath);
|
return $this->_in_progress = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$function($params);
|
$function($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->in_progress = FALSE;
|
$this->_in_progress = FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// END CI_Hooks class
|
|
||||||
|
|
||||||
/* End of file Hooks.php */
|
|
||||||
/* Location: ./system/core/Hooks.php */
|
|
1070
system/core/Input.php
Executable file → Normal file
1070
system/core/Input.php
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
171
system/core/Lang.php
Executable file → Normal file
171
system/core/Lang.php
Executable file → Normal file
@ -1,19 +1,41 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php
|
||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.1.6 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* This content is released under the MIT License (MIT)
|
||||||
* @author ExpressionEngine Dev Team
|
*
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc.
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
* @license http://codeigniter.com/user_guide/license.html
|
*
|
||||||
* @link http://codeigniter.com
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* @since Version 1.0
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language Class
|
* Language Class
|
||||||
@ -21,32 +43,33 @@
|
|||||||
* @package CodeIgniter
|
* @package CodeIgniter
|
||||||
* @subpackage Libraries
|
* @subpackage Libraries
|
||||||
* @category Language
|
* @category Language
|
||||||
* @author ExpressionEngine Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/libraries/language.html
|
* @link https://codeigniter.com/user_guide/libraries/language.html
|
||||||
*/
|
*/
|
||||||
class CI_Lang {
|
class CI_Lang {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of translations
|
* List of translations
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $language = array();
|
public $language = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of loaded language files
|
* List of loaded language files
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
var $is_loaded = array();
|
public $is_loaded = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
* @access public
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
log_message('debug', "Language Class Initialized");
|
log_message('info', 'Language Class Initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -54,98 +77,122 @@ class CI_Lang {
|
|||||||
/**
|
/**
|
||||||
* Load a language file
|
* Load a language file
|
||||||
*
|
*
|
||||||
* @access public
|
* @param mixed $langfile Language file name
|
||||||
* @param mixed the name of the language file to be loaded. Can be an array
|
* @param string $idiom Language name (english, etc.)
|
||||||
* @param string the language (english, etc.)
|
* @param bool $return Whether to return the loaded array of translations
|
||||||
* @param bool return loaded array of translations
|
* @param bool $add_suffix Whether to add suffix to $langfile
|
||||||
* @param bool add suffix to $langfile
|
* @param string $alt_path Alternative path to look for the language file
|
||||||
* @param string alternative path to look for language file
|
*
|
||||||
* @return mixed
|
* @return void|string[] Array containing translations, if $return is set to TRUE
|
||||||
*/
|
*/
|
||||||
function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
|
public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
|
||||||
{
|
{
|
||||||
|
if (is_array($langfile))
|
||||||
|
{
|
||||||
|
foreach ($langfile as $value)
|
||||||
|
{
|
||||||
|
$this->load($value, $idiom, $return, $add_suffix, $alt_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$langfile = str_replace('.php', '', $langfile);
|
$langfile = str_replace('.php', '', $langfile);
|
||||||
|
|
||||||
if ($add_suffix == TRUE)
|
if ($add_suffix === TRUE)
|
||||||
{
|
{
|
||||||
$langfile = str_replace('_lang.', '', $langfile).'_lang';
|
$langfile = preg_replace('/_lang$/', '', $langfile).'_lang';
|
||||||
}
|
}
|
||||||
|
|
||||||
$langfile .= '.php';
|
$langfile .= '.php';
|
||||||
|
|
||||||
if (in_array($langfile, $this->is_loaded, TRUE))
|
if (empty($idiom) OR ! preg_match('/^[a-z_-]+$/i', $idiom))
|
||||||
|
{
|
||||||
|
$config =& get_config();
|
||||||
|
$idiom = empty($config['language']) ? 'english' : $config['language'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($return === FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = get_config();
|
// Load the base file, so any others found can override it
|
||||||
|
$basepath = BASEPATH.'language/'.$idiom.'/'.$langfile;
|
||||||
if ($idiom == '')
|
if (($found = file_exists($basepath)) === TRUE)
|
||||||
{
|
{
|
||||||
$deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language'];
|
include($basepath);
|
||||||
$idiom = ($deft_lang == '') ? 'english' : $deft_lang;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine where the language file is and load it
|
// Do we have an alternative path to look in?
|
||||||
if ($alt_path != '' && file_exists($alt_path.'language/'.$idiom.'/'.$langfile))
|
if ($alt_path !== '')
|
||||||
{
|
{
|
||||||
include($alt_path.'language/'.$idiom.'/'.$langfile);
|
$alt_path .= 'language/'.$idiom.'/'.$langfile;
|
||||||
|
if (file_exists($alt_path))
|
||||||
|
{
|
||||||
|
include($alt_path);
|
||||||
|
$found = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$found = FALSE;
|
|
||||||
|
|
||||||
foreach (get_instance()->load->get_package_paths(TRUE) as $package_path)
|
foreach (get_instance()->load->get_package_paths(TRUE) as $package_path)
|
||||||
{
|
{
|
||||||
if (file_exists($package_path.'language/'.$idiom.'/'.$langfile))
|
$package_path .= 'language/'.$idiom.'/'.$langfile;
|
||||||
|
if ($basepath !== $package_path && file_exists($package_path))
|
||||||
{
|
{
|
||||||
include($package_path.'language/'.$idiom.'/'.$langfile);
|
include($package_path);
|
||||||
$found = TRUE;
|
$found = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($found !== TRUE)
|
|
||||||
{
|
|
||||||
show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($found !== TRUE)
|
||||||
|
{
|
||||||
|
show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! isset($lang))
|
if ( ! isset($lang) OR ! is_array($lang))
|
||||||
{
|
{
|
||||||
log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
|
log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
|
||||||
|
|
||||||
|
if ($return === TRUE)
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($return == TRUE)
|
if ($return === TRUE)
|
||||||
{
|
{
|
||||||
return $lang;
|
return $lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->is_loaded[] = $langfile;
|
$this->is_loaded[$langfile] = $idiom;
|
||||||
$this->language = array_merge($this->language, $lang);
|
$this->language = array_merge($this->language, $lang);
|
||||||
unset($lang);
|
|
||||||
|
|
||||||
log_message('debug', 'Language file loaded: language/'.$idiom.'/'.$langfile);
|
log_message('info', 'Language file loaded: language/'.$idiom.'/'.$langfile);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a single line of text from the language array
|
* Language line
|
||||||
*
|
*
|
||||||
* @access public
|
* Fetches a single line of text from the language array
|
||||||
* @param string $line the language line
|
*
|
||||||
* @return string
|
* @param string $line Language line key
|
||||||
|
* @param bool $log_errors Whether to log an error message if the line is not found
|
||||||
|
* @return string Translation
|
||||||
*/
|
*/
|
||||||
function line($line = '')
|
public function line($line, $log_errors = TRUE)
|
||||||
{
|
{
|
||||||
$value = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line];
|
$value = isset($this->language[$line]) ? $this->language[$line] : FALSE;
|
||||||
|
|
||||||
// Because killer robots like unicorns!
|
// Because killer robots like unicorns!
|
||||||
if ($value === FALSE)
|
if ($value === FALSE && $log_errors === TRUE)
|
||||||
{
|
{
|
||||||
log_message('error', 'Could not find the language line "'.$line.'"');
|
log_message('error', 'Could not find the language line "'.$line.'"');
|
||||||
}
|
}
|
||||||
@ -154,7 +201,3 @@ class CI_Lang {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// END Language Class
|
|
||||||
|
|
||||||
/* End of file Lang.php */
|
|
||||||
/* Location: ./system/core/Lang.php */
|
|
||||||
|
1241
system/core/Loader.php
Executable file → Normal file
1241
system/core/Loader.php
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
296
system/core/Log.php
Normal file
296
system/core/Log.php
Normal file
@ -0,0 +1,296 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP
|
||||||
|
*
|
||||||
|
* This content is released under the MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logging Class
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Libraries
|
||||||
|
* @category Logging
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @link https://codeigniter.com/user_guide/general/errors.html
|
||||||
|
*/
|
||||||
|
class CI_Log {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to save log files
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $_log_path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File permissions
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $_file_permissions = 0644;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Level of logging
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $_threshold = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of threshold levels to log
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $_threshold_array = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format of timestamp for log files
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $_date_fmt = 'Y-m-d H:i:s';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filename extension
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $_file_ext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not the logger can write to the log files
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $_enabled = TRUE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Predefined logging levels
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $_levels = array('ERROR' => 1, 'DEBUG' => 2, 'INFO' => 3, 'ALL' => 4);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mbstring.func_overload flag
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected static $func_overload;
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$config =& get_config();
|
||||||
|
|
||||||
|
isset(self::$func_overload) OR self::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
|
||||||
|
|
||||||
|
$this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/';
|
||||||
|
$this->_file_ext = (isset($config['log_file_extension']) && $config['log_file_extension'] !== '')
|
||||||
|
? ltrim($config['log_file_extension'], '.') : 'php';
|
||||||
|
|
||||||
|
file_exists($this->_log_path) OR mkdir($this->_log_path, 0755, TRUE);
|
||||||
|
|
||||||
|
if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path))
|
||||||
|
{
|
||||||
|
$this->_enabled = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_numeric($config['log_threshold']))
|
||||||
|
{
|
||||||
|
$this->_threshold = (int) $config['log_threshold'];
|
||||||
|
}
|
||||||
|
elseif (is_array($config['log_threshold']))
|
||||||
|
{
|
||||||
|
$this->_threshold = 0;
|
||||||
|
$this->_threshold_array = array_flip($config['log_threshold']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty($config['log_date_format']))
|
||||||
|
{
|
||||||
|
$this->_date_fmt = $config['log_date_format'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty($config['log_file_permissions']) && is_int($config['log_file_permissions']))
|
||||||
|
{
|
||||||
|
$this->_file_permissions = $config['log_file_permissions'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write Log File
|
||||||
|
*
|
||||||
|
* Generally this function will be called using the global log_message() function
|
||||||
|
*
|
||||||
|
* @param string $level The error level: 'error', 'debug' or 'info'
|
||||||
|
* @param string $msg The error message
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function write_log($level, $msg)
|
||||||
|
{
|
||||||
|
if ($this->_enabled === FALSE)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$level = strtoupper($level);
|
||||||
|
|
||||||
|
if (( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
|
||||||
|
&& ! isset($this->_threshold_array[$this->_levels[$level]]))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$filepath = $this->_log_path.'log-'.date('Y-m-d').'.'.$this->_file_ext;
|
||||||
|
$message = '';
|
||||||
|
|
||||||
|
if ( ! file_exists($filepath))
|
||||||
|
{
|
||||||
|
$newfile = TRUE;
|
||||||
|
// Only add protection to php files
|
||||||
|
if ($this->_file_ext === 'php')
|
||||||
|
{
|
||||||
|
$message .= "<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>\n\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! $fp = @fopen($filepath, 'ab'))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
flock($fp, LOCK_EX);
|
||||||
|
|
||||||
|
// Instantiating DateTime with microseconds appended to initial date is needed for proper support of this format
|
||||||
|
if (strpos($this->_date_fmt, 'u') !== FALSE)
|
||||||
|
{
|
||||||
|
$microtime_full = microtime(TRUE);
|
||||||
|
$microtime_short = sprintf("%06d", ($microtime_full - floor($microtime_full)) * 1000000);
|
||||||
|
$date = new DateTime(date('Y-m-d H:i:s.'.$microtime_short, $microtime_full));
|
||||||
|
$date = $date->format($this->_date_fmt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$date = date($this->_date_fmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
$message .= $this->_format_line($level, $date, $msg);
|
||||||
|
|
||||||
|
for ($written = 0, $length = self::strlen($message); $written < $length; $written += $result)
|
||||||
|
{
|
||||||
|
if (($result = fwrite($fp, self::substr($message, $written))) === FALSE)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flock($fp, LOCK_UN);
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
if (isset($newfile) && $newfile === TRUE)
|
||||||
|
{
|
||||||
|
chmod($filepath, $this->_file_permissions);
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_int($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the log line.
|
||||||
|
*
|
||||||
|
* This is for extensibility of log formatting
|
||||||
|
* If you want to change the log format, extend the CI_Log class and override this method
|
||||||
|
*
|
||||||
|
* @param string $level The error level
|
||||||
|
* @param string $date Formatted date string
|
||||||
|
* @param string $message The log message
|
||||||
|
* @return string Formatted log line with a new line character '\n' at the end
|
||||||
|
*/
|
||||||
|
protected function _format_line($level, $date, $message)
|
||||||
|
{
|
||||||
|
return $level.' - '.$date.' --> '.$message."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Byte-safe strlen()
|
||||||
|
*
|
||||||
|
* @param string $str
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
protected static function strlen($str)
|
||||||
|
{
|
||||||
|
return (self::$func_overload)
|
||||||
|
? mb_strlen($str, '8bit')
|
||||||
|
: strlen($str);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Byte-safe substr()
|
||||||
|
*
|
||||||
|
* @param string $str
|
||||||
|
* @param int $start
|
||||||
|
* @param int $length
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected static function substr($str, $start, $length = NULL)
|
||||||
|
{
|
||||||
|
if (self::$func_overload)
|
||||||
|
{
|
||||||
|
// mb_substr($str, $start, null, '8bit') returns an empty
|
||||||
|
// string on PHP 5.3
|
||||||
|
isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
|
||||||
|
return mb_substr($str, $start, $length, '8bit');
|
||||||
|
}
|
||||||
|
|
||||||
|
return isset($length)
|
||||||
|
? substr($str, $start, $length)
|
||||||
|
: substr($str, $start);
|
||||||
|
}
|
||||||
|
}
|
77
system/core/Model.php
Executable file → Normal file
77
system/core/Model.php
Executable file → Normal file
@ -1,57 +1,76 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php
|
||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.1.6 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* This content is released under the MIT License (MIT)
|
||||||
* @author ExpressionEngine Dev Team
|
*
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc.
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
* @license http://codeigniter.com/user_guide/license.html
|
*
|
||||||
* @link http://codeigniter.com
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* @since Version 1.0
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CodeIgniter Model Class
|
* Model Class
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* @package CodeIgniter
|
||||||
* @subpackage Libraries
|
* @subpackage Libraries
|
||||||
* @category Libraries
|
* @category Libraries
|
||||||
* @author ExpressionEngine Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/libraries/config.html
|
* @link https://codeigniter.com/user_guide/libraries/config.html
|
||||||
*/
|
*/
|
||||||
class CI_Model {
|
class CI_Model {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
* @access public
|
* @link https://github.com/bcit-ci/CodeIgniter/issues/5332
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct() {}
|
||||||
{
|
|
||||||
log_message('debug', "Model Class Initialized");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __get
|
* __get magic
|
||||||
*
|
*
|
||||||
* Allows models to access CI's loaded classes using the same
|
* Allows models to access CI's loaded classes using the same
|
||||||
* syntax as controllers.
|
* syntax as controllers.
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string $key
|
||||||
* @access private
|
|
||||||
*/
|
*/
|
||||||
function __get($key)
|
public function __get($key)
|
||||||
{
|
{
|
||||||
$CI =& get_instance();
|
// Debugging note:
|
||||||
return $CI->$key;
|
// If you're here because you're getting an error message
|
||||||
|
// saying 'Undefined Property: system/core/Model.php', it's
|
||||||
|
// most likely a typo in your model code.
|
||||||
|
return get_instance()->$key;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// END Model Class
|
|
||||||
|
|
||||||
/* End of file Model.php */
|
}
|
||||||
/* Location: ./system/core/Model.php */
|
|
||||||
|
730
system/core/Output.php
Executable file → Normal file
730
system/core/Output.php
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
613
system/core/Router.php
Executable file → Normal file
613
system/core/Router.php
Executable file → Normal file
@ -1,19 +1,41 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php
|
||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.1.6 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* This content is released under the MIT License (MIT)
|
||||||
* @author ExpressionEngine Dev Team
|
*
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc.
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
* @license http://codeigniter.com/user_guide/license.html
|
*
|
||||||
* @link http://codeigniter.com
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* @since Version 1.0
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Router Class
|
* Router Class
|
||||||
@ -22,389 +44,394 @@
|
|||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* @package CodeIgniter
|
||||||
* @subpackage Libraries
|
* @subpackage Libraries
|
||||||
* @author ExpressionEngine Dev Team
|
|
||||||
* @category Libraries
|
* @category Libraries
|
||||||
* @link http://codeigniter.com/user_guide/general/routing.html
|
* @author EllisLab Dev Team
|
||||||
|
* @link https://codeigniter.com/user_guide/general/routing.html
|
||||||
*/
|
*/
|
||||||
class CI_Router {
|
class CI_Router {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config class
|
* CI_Config class object
|
||||||
*
|
*
|
||||||
* @var object
|
* @var object
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $config;
|
public $config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of routes
|
* List of routes
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $routes = array();
|
public $routes = array();
|
||||||
/**
|
|
||||||
* List of error routes
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
var $error_routes = array();
|
|
||||||
/**
|
/**
|
||||||
* Current class name
|
* Current class name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $class = '';
|
public $class = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current method name
|
* Current method name
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $method = 'index';
|
public $method = 'index';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sub-directory that contains the requested controller class
|
* Sub-directory that contains the requested controller class
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $directory = '';
|
public $directory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default controller (and method if specific)
|
* Default controller (and method if specific)
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $default_controller;
|
public $default_controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Translate URI dashes
|
||||||
|
*
|
||||||
|
* Determines whether dashes in controller & method segments
|
||||||
|
* should be automatically replaced by underscores.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $translate_uri_dashes = FALSE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable query strings flag
|
||||||
|
*
|
||||||
|
* Determines whether to use GET parameters or segment URIs
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
public $enable_query_strings = FALSE;
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor
|
||||||
*
|
*
|
||||||
* Runs the route mapping function.
|
* Runs the route mapping function.
|
||||||
|
*
|
||||||
|
* @param array $routing
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct($routing = NULL)
|
||||||
{
|
{
|
||||||
$this->config =& load_class('Config', 'core');
|
$this->config =& load_class('Config', 'core');
|
||||||
$this->uri =& load_class('URI', 'core');
|
$this->uri =& load_class('URI', 'core');
|
||||||
log_message('debug', "Router Class Initialized");
|
|
||||||
|
$this->enable_query_strings = ( ! is_cli() && $this->config->item('enable_query_strings') === TRUE);
|
||||||
|
|
||||||
|
// If a directory override is configured, it has to be set before any dynamic routing logic
|
||||||
|
is_array($routing) && isset($routing['directory']) && $this->set_directory($routing['directory']);
|
||||||
|
$this->_set_routing();
|
||||||
|
|
||||||
|
// Set any routing overrides that may exist in the main index file
|
||||||
|
if (is_array($routing))
|
||||||
|
{
|
||||||
|
empty($routing['controller']) OR $this->set_class($routing['controller']);
|
||||||
|
empty($routing['function']) OR $this->set_method($routing['function']);
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message('info', 'Router Class Initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the route mapping
|
* Set route mapping
|
||||||
*
|
*
|
||||||
* This function determines what should be served based on the URI request,
|
* Determines what should be served based on the URI request,
|
||||||
* as well as any "routes" that have been set in the routing config file.
|
* as well as any "routes" that have been set in the routing config file.
|
||||||
*
|
*
|
||||||
* @access private
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _set_routing()
|
protected function _set_routing()
|
||||||
{
|
{
|
||||||
// Are query strings enabled in the config file? Normally CI doesn't utilize query strings
|
// Load the routes.php file. It would be great if we could
|
||||||
// since URI segments are more search-engine friendly, but they can optionally be used.
|
// skip this for enable_query_strings = TRUE, but then
|
||||||
// If this feature is enabled, we will gather the directory/class/method a little differently
|
// default_controller would be empty ...
|
||||||
$segments = array();
|
if (file_exists(APPPATH.'config/routes.php'))
|
||||||
if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')]))
|
|
||||||
{
|
|
||||||
if (isset($_GET[$this->config->item('directory_trigger')]))
|
|
||||||
{
|
|
||||||
$this->set_directory(trim($this->uri->_filter_uri($_GET[$this->config->item('directory_trigger')])));
|
|
||||||
$segments[] = $this->fetch_directory();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_GET[$this->config->item('controller_trigger')]))
|
|
||||||
{
|
|
||||||
$this->set_class(trim($this->uri->_filter_uri($_GET[$this->config->item('controller_trigger')])));
|
|
||||||
$segments[] = $this->fetch_class();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_GET[$this->config->item('function_trigger')]))
|
|
||||||
{
|
|
||||||
$this->set_method(trim($this->uri->_filter_uri($_GET[$this->config->item('function_trigger')])));
|
|
||||||
$segments[] = $this->fetch_method();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the routes.php file.
|
|
||||||
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
|
|
||||||
{
|
|
||||||
include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
|
|
||||||
}
|
|
||||||
elseif (is_file(APPPATH.'config/routes.php'))
|
|
||||||
{
|
{
|
||||||
include(APPPATH.'config/routes.php');
|
include(APPPATH.'config/routes.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route;
|
if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
|
||||||
unset($route);
|
|
||||||
|
|
||||||
// Set the default controller so we can display it in the event
|
|
||||||
// the URI doesn't correlated to a valid controller.
|
|
||||||
$this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
|
|
||||||
|
|
||||||
// Were there any query string segments? If so, we'll validate them and bail out since we're done.
|
|
||||||
if (count($segments) > 0)
|
|
||||||
{
|
{
|
||||||
return $this->_validate_request($segments);
|
include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the complete URI string
|
// Validate & get reserved routes
|
||||||
$this->uri->_fetch_uri_string();
|
if (isset($route) && is_array($route))
|
||||||
|
|
||||||
// Is there a URI string? If not, the default controller specified in the "routes" file will be shown.
|
|
||||||
if ($this->uri->uri_string == '')
|
|
||||||
{
|
{
|
||||||
return $this->_set_default_controller();
|
isset($route['default_controller']) && $this->default_controller = $route['default_controller'];
|
||||||
|
isset($route['translate_uri_dashes']) && $this->translate_uri_dashes = $route['translate_uri_dashes'];
|
||||||
|
unset($route['default_controller'], $route['translate_uri_dashes']);
|
||||||
|
$this->routes = $route;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we need to remove the URL suffix?
|
// Are query strings enabled in the config file? Normally CI doesn't utilize query strings
|
||||||
$this->uri->_remove_url_suffix();
|
// since URI segments are more search-engine friendly, but they can optionally be used.
|
||||||
|
// If this feature is enabled, we will gather the directory/class/method a little differently
|
||||||
// Compile the segments into an array
|
if ($this->enable_query_strings)
|
||||||
$this->uri->_explode_segments();
|
|
||||||
|
|
||||||
// Parse any custom routing that may exist
|
|
||||||
$this->_parse_routes();
|
|
||||||
|
|
||||||
// Re-index the segment array so that it starts with 1 rather than 0
|
|
||||||
$this->uri->_reindex_segments();
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the default controller
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function _set_default_controller()
|
|
||||||
{
|
|
||||||
if ($this->default_controller === FALSE)
|
|
||||||
{
|
{
|
||||||
show_error("Unable to determine what should be displayed. A default route has not been specified in the routing file.");
|
// If the directory is set at this time, it means an override exists, so skip the checks
|
||||||
|
if ( ! isset($this->directory))
|
||||||
|
{
|
||||||
|
$_d = $this->config->item('directory_trigger');
|
||||||
|
$_d = isset($_GET[$_d]) ? trim($_GET[$_d], " \t\n\r\0\x0B/") : '';
|
||||||
|
|
||||||
|
if ($_d !== '')
|
||||||
|
{
|
||||||
|
$this->uri->filter_uri($_d);
|
||||||
|
$this->set_directory($_d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$_c = trim($this->config->item('controller_trigger'));
|
||||||
|
if ( ! empty($_GET[$_c]))
|
||||||
|
{
|
||||||
|
$this->uri->filter_uri($_GET[$_c]);
|
||||||
|
$this->set_class($_GET[$_c]);
|
||||||
|
|
||||||
|
$_f = trim($this->config->item('function_trigger'));
|
||||||
|
if ( ! empty($_GET[$_f]))
|
||||||
|
{
|
||||||
|
$this->uri->filter_uri($_GET[$_f]);
|
||||||
|
$this->set_method($_GET[$_f]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->uri->rsegments = array(
|
||||||
|
1 => $this->class,
|
||||||
|
2 => $this->method
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->_set_default_controller();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Routing rules don't apply to query strings and we don't need to detect
|
||||||
|
// directories, so we're done here
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
// Is the method being specified?
|
|
||||||
if (strpos($this->default_controller, '/') !== FALSE)
|
|
||||||
{
|
|
||||||
$x = explode('/', $this->default_controller);
|
|
||||||
|
|
||||||
$this->set_class($x[0]);
|
// Is there anything to parse?
|
||||||
$this->set_method($x[1]);
|
if ($this->uri->uri_string !== '')
|
||||||
$this->_set_request($x);
|
{
|
||||||
|
$this->_parse_routes();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->set_class($this->default_controller);
|
$this->_set_default_controller();
|
||||||
$this->set_method('index');
|
|
||||||
$this->_set_request(array($this->default_controller, 'index'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// re-index the routed segments array so it starts with 1 rather than 0
|
|
||||||
$this->uri->_reindex_segments();
|
|
||||||
|
|
||||||
log_message('debug', "No URI present. Default controller set.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the Route
|
* Set request route
|
||||||
*
|
*
|
||||||
* This function takes an array of URI segments as
|
* Takes an array of URI segments as input and sets the class/method
|
||||||
* input, and sets the current class/method
|
* to be called.
|
||||||
*
|
*
|
||||||
* @access private
|
* @used-by CI_Router::_parse_routes()
|
||||||
* @param array
|
* @param array $segments URI segments
|
||||||
* @param bool
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _set_request($segments = array())
|
protected function _set_request($segments = array())
|
||||||
{
|
{
|
||||||
$segments = $this->_validate_request($segments);
|
$segments = $this->_validate_request($segments);
|
||||||
|
// If we don't have any segments left - try the default controller;
|
||||||
if (count($segments) == 0)
|
// WARNING: Directories get shifted out of the segments array!
|
||||||
|
if (empty($segments))
|
||||||
{
|
{
|
||||||
return $this->_set_default_controller();
|
$this->_set_default_controller();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->translate_uri_dashes === TRUE)
|
||||||
|
{
|
||||||
|
$segments[0] = str_replace('-', '_', $segments[0]);
|
||||||
|
if (isset($segments[1]))
|
||||||
|
{
|
||||||
|
$segments[1] = str_replace('-', '_', $segments[1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->set_class($segments[0]);
|
$this->set_class($segments[0]);
|
||||||
|
|
||||||
if (isset($segments[1]))
|
if (isset($segments[1]))
|
||||||
{
|
{
|
||||||
// A standard method request
|
|
||||||
$this->set_method($segments[1]);
|
$this->set_method($segments[1]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// This lets the "routed" segment array identify that the default
|
|
||||||
// index method is being used.
|
|
||||||
$segments[1] = 'index';
|
$segments[1] = 'index';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update our "routed" segment array to contain the segments.
|
array_unshift($segments, NULL);
|
||||||
// Note: If there is no custom routing, this array will be
|
unset($segments[0]);
|
||||||
// identical to $this->uri->segments
|
|
||||||
$this->uri->rsegments = $segments;
|
$this->uri->rsegments = $segments;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates the supplied segments. Attempts to determine the path to
|
* Set default controller
|
||||||
* the controller.
|
|
||||||
*
|
*
|
||||||
* @access private
|
* @return void
|
||||||
* @param array
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
function _validate_request($segments)
|
protected function _set_default_controller()
|
||||||
{
|
{
|
||||||
if (count($segments) == 0)
|
if (empty($this->default_controller))
|
||||||
{
|
{
|
||||||
return $segments;
|
show_error('Unable to determine what should be displayed. A default route has not been specified in the routing file.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Does the requested controller exist in the root folder?
|
// Is the method being specified?
|
||||||
if (file_exists(APPPATH.'controllers/'.$segments[0].'.php'))
|
if (sscanf($this->default_controller, '%[^/]/%s', $class, $method) !== 2)
|
||||||
{
|
{
|
||||||
return $segments;
|
$method = 'index';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is the controller in a sub-folder?
|
if ( ! file_exists(APPPATH.'controllers/'.$this->directory.ucfirst($class).'.php'))
|
||||||
if (is_dir(APPPATH.'controllers/'.$segments[0]))
|
|
||||||
{
|
{
|
||||||
// Set the directory and remove it from the segment array
|
// This will trigger 404 later
|
||||||
$this->set_directory($segments[0]);
|
return;
|
||||||
$segments = array_slice($segments, 1);
|
|
||||||
|
|
||||||
if (count($segments) > 0)
|
|
||||||
{
|
|
||||||
// Does the requested controller exist in the sub-folder?
|
|
||||||
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].'.php'))
|
|
||||||
{
|
|
||||||
if ( ! empty($this->routes['404_override']))
|
|
||||||
{
|
|
||||||
$x = explode('/', $this->routes['404_override']);
|
|
||||||
|
|
||||||
$this->set_directory('');
|
|
||||||
$this->set_class($x[0]);
|
|
||||||
$this->set_method(isset($x[1]) ? $x[1] : 'index');
|
|
||||||
|
|
||||||
return $x;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
show_404($this->fetch_directory().$segments[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Is the method being specified in the route?
|
|
||||||
if (strpos($this->default_controller, '/') !== FALSE)
|
|
||||||
{
|
|
||||||
$x = explode('/', $this->default_controller);
|
|
||||||
|
|
||||||
$this->set_class($x[0]);
|
|
||||||
$this->set_method($x[1]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->set_class($this->default_controller);
|
|
||||||
$this->set_method('index');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Does the default controller exist in the sub-folder?
|
|
||||||
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.'.php'))
|
|
||||||
{
|
|
||||||
$this->directory = '';
|
|
||||||
return array();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return $segments;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->set_class($class);
|
||||||
|
$this->set_method($method);
|
||||||
|
|
||||||
// If we've gotten this far it means that the URI does not correlate to a valid
|
// Assign routed segments, index starting from 1
|
||||||
// controller class. We will now see if there is an override
|
$this->uri->rsegments = array(
|
||||||
if ( ! empty($this->routes['404_override']))
|
1 => $class,
|
||||||
{
|
2 => $method
|
||||||
$x = explode('/', $this->routes['404_override']);
|
);
|
||||||
|
|
||||||
$this->set_class($x[0]);
|
log_message('debug', 'No URI present. Default controller set.');
|
||||||
$this->set_method(isset($x[1]) ? $x[1] : 'index');
|
|
||||||
|
|
||||||
return $x;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Nothing else to do at this point but show a 404
|
|
||||||
show_404($segments[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse Routes
|
* Validate request
|
||||||
*
|
*
|
||||||
* This function matches any routes that may exist in
|
* Attempts validate the URI request and determine the controller path.
|
||||||
* the config/routes.php file against the URI to
|
*
|
||||||
* determine if the class/method need to be remapped.
|
* @used-by CI_Router::_set_request()
|
||||||
|
* @param array $segments URI segments
|
||||||
|
* @return mixed URI segments
|
||||||
|
*/
|
||||||
|
protected function _validate_request($segments)
|
||||||
|
{
|
||||||
|
$c = count($segments);
|
||||||
|
$directory_override = isset($this->directory);
|
||||||
|
|
||||||
|
// Loop through our segments and return as soon as a controller
|
||||||
|
// is found or when such a directory doesn't exist
|
||||||
|
while ($c-- > 0)
|
||||||
|
{
|
||||||
|
$test = $this->directory
|
||||||
|
.ucfirst($this->translate_uri_dashes === TRUE ? str_replace('-', '_', $segments[0]) : $segments[0]);
|
||||||
|
|
||||||
|
if ( ! file_exists(APPPATH.'controllers/'.$test.'.php')
|
||||||
|
&& $directory_override === FALSE
|
||||||
|
&& is_dir(APPPATH.'controllers/'.$this->directory.$segments[0])
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$this->set_directory(array_shift($segments), TRUE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $segments;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This means that all segments were actually directories
|
||||||
|
return $segments;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse Routes
|
||||||
|
*
|
||||||
|
* Matches any routes that may exist in the config/routes.php file
|
||||||
|
* against the URI to determine if the class/method need to be remapped.
|
||||||
*
|
*
|
||||||
* @access private
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _parse_routes()
|
protected function _parse_routes()
|
||||||
{
|
{
|
||||||
// Turn the segment array into a URI string
|
// Turn the segment array into a URI string
|
||||||
$uri = implode('/', $this->uri->segments);
|
$uri = implode('/', $this->uri->segments);
|
||||||
|
|
||||||
// Is there a literal match? If so we're done
|
// Get HTTP verb
|
||||||
if (isset($this->routes[$uri]))
|
$http_verb = isset($_SERVER['REQUEST_METHOD']) ? strtolower($_SERVER['REQUEST_METHOD']) : 'cli';
|
||||||
{
|
|
||||||
return $this->_set_request(explode('/', $this->routes[$uri]));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loop through the route array looking for wild-cards
|
// Loop through the route array looking for wildcards
|
||||||
foreach ($this->routes as $key => $val)
|
foreach ($this->routes as $key => $val)
|
||||||
{
|
{
|
||||||
// Convert wild-cards to RegEx
|
// Check if route format is using HTTP verbs
|
||||||
$key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
|
if (is_array($val))
|
||||||
|
{
|
||||||
|
$val = array_change_key_case($val, CASE_LOWER);
|
||||||
|
if (isset($val[$http_verb]))
|
||||||
|
{
|
||||||
|
$val = $val[$http_verb];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert wildcards to RegEx
|
||||||
|
$key = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $key);
|
||||||
|
|
||||||
// Does the RegEx match?
|
// Does the RegEx match?
|
||||||
if (preg_match('#^'.$key.'$#', $uri))
|
if (preg_match('#^'.$key.'$#', $uri, $matches))
|
||||||
{
|
{
|
||||||
// Do we have a back-reference?
|
// Are we using callbacks to process back-references?
|
||||||
if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE)
|
if ( ! is_string($val) && is_callable($val))
|
||||||
|
{
|
||||||
|
// Remove the original string from the matches array.
|
||||||
|
array_shift($matches);
|
||||||
|
|
||||||
|
// Execute the callback using the values in matches as its parameters.
|
||||||
|
$val = call_user_func_array($val, $matches);
|
||||||
|
}
|
||||||
|
// Are we using the default routing method for back-references?
|
||||||
|
elseif (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE)
|
||||||
{
|
{
|
||||||
$val = preg_replace('#^'.$key.'$#', $val, $uri);
|
$val = preg_replace('#^'.$key.'$#', $val, $uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_set_request(explode('/', $val));
|
$this->_set_request(explode('/', $val));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we got this far it means we didn't encounter a
|
// If we got this far it means we didn't encounter a
|
||||||
// matching route so we'll set the site default route
|
// matching route so we'll set the site default route
|
||||||
$this->_set_request($this->uri->segments);
|
$this->_set_request(array_values($this->uri->segments));
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the class name
|
* Set class name
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $class Class name
|
||||||
* @param string
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function set_class($class)
|
public function set_class($class)
|
||||||
{
|
{
|
||||||
$this->class = str_replace(array('/', '.'), '', $class);
|
$this->class = str_replace(array('/', '.'), '', $class);
|
||||||
}
|
}
|
||||||
@ -414,10 +441,10 @@ class CI_Router {
|
|||||||
/**
|
/**
|
||||||
* Fetch the current class
|
* Fetch the current class
|
||||||
*
|
*
|
||||||
* @access public
|
* @deprecated 3.0.0 Read the 'class' property instead
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function fetch_class()
|
public function fetch_class()
|
||||||
{
|
{
|
||||||
return $this->class;
|
return $this->class;
|
||||||
}
|
}
|
||||||
@ -425,13 +452,12 @@ class CI_Router {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the method name
|
* Set method name
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $method Method name
|
||||||
* @param string
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function set_method($method)
|
public function set_method($method)
|
||||||
{
|
{
|
||||||
$this->method = $method;
|
$this->method = $method;
|
||||||
}
|
}
|
||||||
@ -439,84 +465,51 @@ class CI_Router {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the current method
|
* Fetch the current method
|
||||||
*
|
*
|
||||||
* @access public
|
* @deprecated 3.0.0 Read the 'method' property instead
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function fetch_method()
|
public function fetch_method()
|
||||||
{
|
{
|
||||||
if ($this->method == $this->fetch_class())
|
|
||||||
{
|
|
||||||
return 'index';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->method;
|
return $this->method;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the directory name
|
* Set directory name
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $dir Directory name
|
||||||
* @param string
|
* @param bool $append Whether we're appending rather than setting the full value
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function set_directory($dir)
|
public function set_directory($dir, $append = FALSE)
|
||||||
{
|
{
|
||||||
$this->directory = str_replace(array('/', '.'), '', $dir).'/';
|
if ($append !== TRUE OR empty($this->directory))
|
||||||
|
{
|
||||||
|
$this->directory = str_replace('.', '', trim($dir, '/')).'/';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->directory .= str_replace('.', '', trim($dir, '/')).'/';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the sub-directory (if any) that contains the requested controller class
|
* Fetch directory
|
||||||
*
|
*
|
||||||
* @access public
|
* Feches the sub-directory (if any) that contains the requested
|
||||||
|
* controller class.
|
||||||
|
*
|
||||||
|
* @deprecated 3.0.0 Read the 'directory' property instead
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function fetch_directory()
|
public function fetch_directory()
|
||||||
{
|
{
|
||||||
return $this->directory;
|
return $this->directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the controller overrides
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param array
|
|
||||||
* @return null
|
|
||||||
*/
|
|
||||||
function _set_overrides($routing)
|
|
||||||
{
|
|
||||||
if ( ! is_array($routing))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($routing['directory']))
|
|
||||||
{
|
|
||||||
$this->set_directory($routing['directory']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($routing['controller']) AND $routing['controller'] != '')
|
|
||||||
{
|
|
||||||
$this->set_class($routing['controller']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($routing['function']))
|
|
||||||
{
|
|
||||||
$routing['function'] = ($routing['function'] == '') ? 'index' : $routing['function'];
|
|
||||||
$this->set_method($routing['function']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// END Router Class
|
|
||||||
|
|
||||||
/* End of file Router.php */
|
|
||||||
/* Location: ./system/core/Router.php */
|
|
953
system/core/Security.php
Executable file → Normal file
953
system/core/Security.php
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
669
system/core/URI.php
Executable file → Normal file
669
system/core/URI.php
Executable file → Normal file
@ -1,19 +1,41 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php
|
||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.1.6 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* This content is released under the MIT License (MIT)
|
||||||
* @author ExpressionEngine Dev Team
|
*
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc.
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
* @license http://codeigniter.com/user_guide/license.html
|
*
|
||||||
* @link http://codeigniter.com
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* @since Version 1.0
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* URI Class
|
* URI Class
|
||||||
@ -23,382 +45,368 @@
|
|||||||
* @package CodeIgniter
|
* @package CodeIgniter
|
||||||
* @subpackage Libraries
|
* @subpackage Libraries
|
||||||
* @category URI
|
* @category URI
|
||||||
* @author ExpressionEngine Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/libraries/uri.html
|
* @link https://codeigniter.com/user_guide/libraries/uri.html
|
||||||
*/
|
*/
|
||||||
class CI_URI {
|
class CI_URI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of cached uri segments
|
* List of cached URI segments
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
var $keyval = array();
|
public $keyval = array();
|
||||||
/**
|
|
||||||
* Current uri string
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
var $uri_string;
|
|
||||||
/**
|
|
||||||
* List of uri segments
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
var $segments = array();
|
|
||||||
/**
|
|
||||||
* Re-indexed list of uri segments
|
|
||||||
* Starts at 1 instead of 0
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
var $rsegments = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Current URI string
|
||||||
*
|
*
|
||||||
* Simply globalizes the $RTR object. The front
|
* @var string
|
||||||
* loads the Router class early on so it's not available
|
|
||||||
* normally as other classes are.
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public $uri_string = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of URI segments
|
||||||
|
*
|
||||||
|
* Starts at 1 instead of 0.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $segments = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of routed URI segments
|
||||||
|
*
|
||||||
|
* Starts at 1 instead of 0.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $rsegments = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permitted URI chars
|
||||||
|
*
|
||||||
|
* PCRE character group allowed in URI segments
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $_permitted_uri_chars;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->config =& load_class('Config', 'core');
|
$this->config =& load_class('Config', 'core');
|
||||||
log_message('debug', "URI Class Initialized");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// 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)
|
||||||
/**
|
|
||||||
* Get the URI String
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function _fetch_uri_string()
|
|
||||||
{
|
|
||||||
if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
|
|
||||||
{
|
{
|
||||||
// Is the request coming from the command line?
|
$this->_permitted_uri_chars = $this->config->item('permitted_uri_chars');
|
||||||
if (php_sapi_name() == 'cli' or defined('STDIN'))
|
|
||||||
|
// If it's a CLI request, ignore the configuration
|
||||||
|
if (is_cli())
|
||||||
{
|
{
|
||||||
$this->_set_uri_string($this->_parse_cli_args());
|
$uri = $this->_parse_argv();
|
||||||
return;
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's try the REQUEST_URI first, this will work in most situations
|
$this->_set_uri_string($uri);
|
||||||
if ($uri = $this->_detect_uri())
|
|
||||||
{
|
|
||||||
$this->_set_uri_string($uri);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is there a PATH_INFO variable?
|
|
||||||
// Note: some servers seem to have trouble with getenv() so we'll test it two ways
|
|
||||||
$path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
|
|
||||||
if (trim($path, '/') != '' && $path != "/".SELF)
|
|
||||||
{
|
|
||||||
$this->_set_uri_string($path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// No PATH_INFO?... What about QUERY_STRING?
|
|
||||||
$path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
|
|
||||||
if (trim($path, '/') != '')
|
|
||||||
{
|
|
||||||
$this->_set_uri_string($path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// As a last ditch effort lets try using the $_GET array
|
|
||||||
if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '')
|
|
||||||
{
|
|
||||||
$this->_set_uri_string(key($_GET));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We've exhausted all our options...
|
|
||||||
$this->uri_string = '';
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri = strtoupper($this->config->item('uri_protocol'));
|
log_message('info', 'URI Class Initialized');
|
||||||
|
|
||||||
if ($uri == 'REQUEST_URI')
|
|
||||||
{
|
|
||||||
$this->_set_uri_string($this->_detect_uri());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
elseif ($uri == 'CLI')
|
|
||||||
{
|
|
||||||
$this->_set_uri_string($this->_parse_cli_args());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$path = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
|
|
||||||
$this->_set_uri_string($path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the URI String
|
* Set URI String
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $str
|
||||||
* @param string
|
* @return void
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
function _set_uri_string($str)
|
protected function _set_uri_string($str)
|
||||||
{
|
{
|
||||||
// Filter out control characters
|
// Filter out control characters and trim slashes
|
||||||
$str = remove_invisible_characters($str, FALSE);
|
$this->uri_string = trim(remove_invisible_characters($str, FALSE), '/');
|
||||||
|
|
||||||
// If the URI contains only a slash we'll kill it
|
if ($this->uri_string !== '')
|
||||||
$this->uri_string = ($str == '/') ? '' : $str;
|
{
|
||||||
|
// 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;
|
||||||
|
// Populate the segments array
|
||||||
|
foreach (explode('/', trim($this->uri_string, '/')) as $val)
|
||||||
|
{
|
||||||
|
$val = trim($val);
|
||||||
|
// Filter segments for security
|
||||||
|
$this->filter_uri($val);
|
||||||
|
|
||||||
|
if ($val !== '')
|
||||||
|
{
|
||||||
|
$this->segments[] = $val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($this->segments[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detects the URI
|
* Parse REQUEST_URI
|
||||||
*
|
*
|
||||||
* This function will detect the URI automatically and fix the query string
|
* Will parse REQUEST_URI and automatically detect the URI from it,
|
||||||
* if necessary.
|
* while fixing the query string if necessary.
|
||||||
*
|
*
|
||||||
* @access private
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function _detect_uri()
|
protected function _parse_request_uri()
|
||||||
{
|
{
|
||||||
if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME']))
|
if ( ! isset($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']))
|
||||||
{
|
{
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri = $_SERVER['REQUEST_URI'];
|
// parse_url() returns false if no host is present, but the path or query string
|
||||||
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
|
// contains a colon followed by a number
|
||||||
|
$uri = parse_url('http://dummy'.$_SERVER['REQUEST_URI']);
|
||||||
|
$query = isset($uri['query']) ? $uri['query'] : '';
|
||||||
|
$uri = isset($uri['path']) ? $uri['path'] : '';
|
||||||
|
|
||||||
|
if (isset($_SERVER['SCRIPT_NAME'][0]))
|
||||||
{
|
{
|
||||||
$uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
|
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
|
||||||
}
|
{
|
||||||
elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
|
$uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME']));
|
||||||
{
|
}
|
||||||
$uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
|
elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
|
||||||
|
{
|
||||||
|
$uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
|
// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
|
||||||
// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
|
// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
|
||||||
if (strncmp($uri, '?/', 2) === 0)
|
if (trim($uri, '/') === '' && strncmp($query, '/', 1) === 0)
|
||||||
{
|
{
|
||||||
$uri = substr($uri, 2);
|
$query = explode('?', $query, 2);
|
||||||
}
|
$uri = $query[0];
|
||||||
$parts = preg_split('#\?#i', $uri, 2);
|
$_SERVER['QUERY_STRING'] = isset($query[1]) ? $query[1] : '';
|
||||||
$uri = $parts[0];
|
|
||||||
if (isset($parts[1]))
|
|
||||||
{
|
|
||||||
$_SERVER['QUERY_STRING'] = $parts[1];
|
|
||||||
parse_str($_SERVER['QUERY_STRING'], $_GET);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$_SERVER['QUERY_STRING'] = '';
|
$_SERVER['QUERY_STRING'] = $query;
|
||||||
$_GET = array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($uri == '/' || empty($uri))
|
parse_str($_SERVER['QUERY_STRING'], $_GET);
|
||||||
|
|
||||||
|
if ($uri === '/' OR $uri === '')
|
||||||
{
|
{
|
||||||
return '/';
|
return '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri = parse_url($uri, PHP_URL_PATH);
|
|
||||||
|
|
||||||
// Do some final cleaning of the URI and return it
|
// Do some final cleaning of the URI and return it
|
||||||
return str_replace(array('//', '../'), '/', trim($uri, '/'));
|
return $this->_remove_relative_directory($uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse cli arguments
|
* Parse QUERY_STRING
|
||||||
|
*
|
||||||
|
* Will parse QUERY_STRING and automatically detect the URI from it.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function _parse_query_string()
|
||||||
|
{
|
||||||
|
$uri = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
|
||||||
|
|
||||||
|
if (trim($uri, '/') === '')
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
elseif (strncmp($uri, '/', 1) === 0)
|
||||||
|
{
|
||||||
|
$uri = explode('?', $uri, 2);
|
||||||
|
$_SERVER['QUERY_STRING'] = isset($uri[1]) ? $uri[1] : '';
|
||||||
|
$uri = $uri[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_str($_SERVER['QUERY_STRING'], $_GET);
|
||||||
|
|
||||||
|
return $this->_remove_relative_directory($uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse CLI arguments
|
||||||
*
|
*
|
||||||
* Take each command line argument and assume it is a URI segment.
|
* Take each command line argument and assume it is a URI segment.
|
||||||
*
|
*
|
||||||
* @access private
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function _parse_cli_args()
|
protected function _parse_argv()
|
||||||
{
|
{
|
||||||
$args = array_slice($_SERVER['argv'], 1);
|
$args = array_slice($_SERVER['argv'], 1);
|
||||||
|
return $args ? implode('/', $args) : '';
|
||||||
return $args ? '/' . implode('/', $args) : '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter segments for malicious characters
|
* Remove relative directory (../) and multi slashes (///)
|
||||||
*
|
*
|
||||||
* @access private
|
* Do some final cleaning of the URI and return it, currently only used in self::_parse_request_uri()
|
||||||
* @param string
|
*
|
||||||
|
* @param string $uri
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _filter_uri($str)
|
protected function _remove_relative_directory($uri)
|
||||||
{
|
{
|
||||||
if ($str != '' && $this->config->item('permitted_uri_chars') != '' && $this->config->item('enable_query_strings') == FALSE)
|
$uris = array();
|
||||||
|
$tok = strtok($uri, '/');
|
||||||
|
while ($tok !== FALSE)
|
||||||
{
|
{
|
||||||
// preg_quote() in PHP 5.3 escapes -, so the str_replace() and addition of - to preg_quote() is to maintain backwards
|
if (( ! empty($tok) OR $tok === '0') && $tok !== '..')
|
||||||
// compatibility as many are unaware of how characters in the permitted_uri_chars will be parsed as a regex pattern
|
|
||||||
if ( ! preg_match("|^[".str_replace(array('\\-', '\-'), '-', preg_quote($this->config->item('permitted_uri_chars'), '-'))."]+$|i", $str))
|
|
||||||
{
|
{
|
||||||
show_error('The URI you submitted has disallowed characters.', 400);
|
$uris[] = $tok;
|
||||||
}
|
}
|
||||||
|
$tok = strtok('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert programatic characters to entities
|
return implode('/', $uris);
|
||||||
$bad = array('$', '(', ')', '%28', '%29');
|
|
||||||
$good = array('$', '(', ')', '(', ')');
|
|
||||||
|
|
||||||
return str_replace($bad, $good, $str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the suffix from the URL if needed
|
* Filter URI
|
||||||
*
|
*
|
||||||
* @access private
|
* Filters segments for malicious characters.
|
||||||
|
*
|
||||||
|
* @param string $str
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _remove_url_suffix()
|
public function filter_uri(&$str)
|
||||||
{
|
{
|
||||||
if ($this->config->item('url_suffix') != "")
|
if ( ! empty($str) && ! empty($this->_permitted_uri_chars) && ! preg_match('/^['.$this->_permitted_uri_chars.']+$/i'.(UTF8_ENABLED ? 'u' : ''), $str))
|
||||||
{
|
{
|
||||||
$this->uri_string = preg_replace("|".preg_quote($this->config->item('url_suffix'))."$|", "", $this->uri_string);
|
show_error('The URI you submitted has disallowed characters.', 400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Explode the URI Segments. The individual segments will
|
* Fetch URI Segment
|
||||||
* be stored in the $this->segments array.
|
|
||||||
*
|
*
|
||||||
* @access private
|
* @see CI_URI::$segments
|
||||||
* @return void
|
* @param int $n Index
|
||||||
|
* @param mixed $no_result What to return if the segment index is not found
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function _explode_segments()
|
public function segment($n, $no_result = NULL)
|
||||||
{
|
{
|
||||||
foreach (explode("/", preg_replace("|/*(.+?)/*$|", "\\1", $this->uri_string)) as $val)
|
return isset($this->segments[$n]) ? $this->segments[$n] : $no_result;
|
||||||
{
|
|
||||||
// Filter segments for security
|
|
||||||
$val = trim($this->_filter_uri($val));
|
|
||||||
|
|
||||||
if ($val != '')
|
|
||||||
{
|
|
||||||
$this->segments[] = $val;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Re-index Segments
|
|
||||||
*
|
|
||||||
* This function re-indexes the $this->segment array so that it
|
|
||||||
* starts at 1 rather than 0. Doing so makes it simpler to
|
|
||||||
* use functions like $this->uri->segment(n) since there is
|
|
||||||
* a 1:1 relationship between the segment array and the actual segments.
|
|
||||||
*
|
|
||||||
* @access private
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function _reindex_segments()
|
|
||||||
{
|
|
||||||
array_unshift($this->segments, NULL);
|
|
||||||
array_unshift($this->rsegments, NULL);
|
|
||||||
unset($this->segments[0]);
|
|
||||||
unset($this->rsegments[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a URI Segment
|
* Fetch URI "routed" Segment
|
||||||
*
|
*
|
||||||
* This function returns the URI segment based on the number provided.
|
* Returns the re-routed URI segment (assuming routing rules are used)
|
||||||
|
* based on the index provided. If there is no routing, will return
|
||||||
|
* the same result as CI_URI::segment().
|
||||||
*
|
*
|
||||||
* @access public
|
* @see CI_URI::$rsegments
|
||||||
* @param integer
|
* @see CI_URI::segment()
|
||||||
* @param bool
|
* @param int $n Index
|
||||||
* @return string
|
* @param mixed $no_result What to return if the segment index is not found
|
||||||
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function segment($n, $no_result = FALSE)
|
public function rsegment($n, $no_result = NULL)
|
||||||
{
|
{
|
||||||
return ( ! isset($this->segments[$n])) ? $no_result : $this->segments[$n];
|
return isset($this->rsegments[$n]) ? $this->rsegments[$n] : $no_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a URI "routed" Segment
|
* URI to assoc
|
||||||
*
|
*
|
||||||
* This function returns the re-routed URI segment (assuming routing rules are used)
|
* Generates an associative array of URI data starting at the supplied
|
||||||
* based on the number provided. If there is no routing this function returns the
|
* segment index. For example, if this is your URI:
|
||||||
* same result as $this->segment()
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @param integer
|
|
||||||
* @param bool
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function rsegment($n, $no_result = FALSE)
|
|
||||||
{
|
|
||||||
return ( ! isset($this->rsegments[$n])) ? $no_result : $this->rsegments[$n];
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a key value pair from the URI string
|
|
||||||
*
|
|
||||||
* This function generates and associative array of URI data starting
|
|
||||||
* at the supplied segment. For example, if this is your URI:
|
|
||||||
*
|
*
|
||||||
* example.com/user/search/name/joe/location/UK/gender/male
|
* example.com/user/search/name/joe/location/UK/gender/male
|
||||||
*
|
*
|
||||||
* You can use this function to generate an array with this prototype:
|
* You can use this method to generate an array with this prototype:
|
||||||
*
|
*
|
||||||
* array (
|
* array (
|
||||||
* name => joe
|
* name => joe
|
||||||
* location => UK
|
* location => UK
|
||||||
* gender => male
|
* gender => male
|
||||||
* )
|
* )
|
||||||
*
|
*
|
||||||
* @access public
|
* @param int $n Index (default: 3)
|
||||||
* @param integer the starting segment number
|
* @param array $default Default values
|
||||||
* @param array an array of default values
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function uri_to_assoc($n = 3, $default = array())
|
public function uri_to_assoc($n = 3, $default = array())
|
||||||
{
|
{
|
||||||
return $this->_uri_to_assoc($n, $default, 'segment');
|
return $this->_uri_to_assoc($n, $default, 'segment');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identical to above only it uses the re-routed segment array
|
* Routed URI to assoc
|
||||||
*
|
*
|
||||||
* @access public
|
* Identical to CI_URI::uri_to_assoc(), only it uses the re-routed
|
||||||
* @param integer the starting segment number
|
* segment array.
|
||||||
* @param array an array of default values
|
*
|
||||||
|
* @see CI_URI::uri_to_assoc()
|
||||||
|
* @param int $n Index (default: 3)
|
||||||
|
* @param array $default Default values
|
||||||
* @return array
|
* @return array
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
function ruri_to_assoc($n = 3, $default = array())
|
public function ruri_to_assoc($n = 3, $default = array())
|
||||||
{
|
{
|
||||||
return $this->_uri_to_assoc($n, $default, 'rsegment');
|
return $this->_uri_to_assoc($n, $default, 'rsegment');
|
||||||
}
|
}
|
||||||
@ -406,57 +414,43 @@ class CI_URI {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a key value pair from the URI string or Re-routed URI string
|
* Internal URI-to-assoc
|
||||||
*
|
*
|
||||||
* @access private
|
* Generates a key/value pair from the URI string or re-routed URI string.
|
||||||
* @param integer the starting segment number
|
*
|
||||||
* @param array an array of default values
|
* @used-by CI_URI::uri_to_assoc()
|
||||||
* @param string which array we should use
|
* @used-by CI_URI::ruri_to_assoc()
|
||||||
|
* @param int $n Index (default: 3)
|
||||||
|
* @param array $default Default values
|
||||||
|
* @param string $which Array name ('segment' or 'rsegment')
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _uri_to_assoc($n = 3, $default = array(), $which = 'segment')
|
protected function _uri_to_assoc($n = 3, $default = array(), $which = 'segment')
|
||||||
{
|
{
|
||||||
if ($which == 'segment')
|
|
||||||
{
|
|
||||||
$total_segments = 'total_segments';
|
|
||||||
$segment_array = 'segment_array';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$total_segments = 'total_rsegments';
|
|
||||||
$segment_array = 'rsegment_array';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! is_numeric($n))
|
if ( ! is_numeric($n))
|
||||||
{
|
{
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->keyval[$n]))
|
if (isset($this->keyval[$which], $this->keyval[$which][$n]))
|
||||||
{
|
{
|
||||||
return $this->keyval[$n];
|
return $this->keyval[$which][$n];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$total_segments = "total_{$which}s";
|
||||||
|
$segment_array = "{$which}_array";
|
||||||
|
|
||||||
if ($this->$total_segments() < $n)
|
if ($this->$total_segments() < $n)
|
||||||
{
|
{
|
||||||
if (count($default) == 0)
|
return (count($default) === 0)
|
||||||
{
|
? array()
|
||||||
return array();
|
: array_fill_keys($default, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
$retval = array();
|
|
||||||
foreach ($default as $val)
|
|
||||||
{
|
|
||||||
$retval[$val] = FALSE;
|
|
||||||
}
|
|
||||||
return $retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$segments = array_slice($this->$segment_array(), ($n - 1));
|
$segments = array_slice($this->$segment_array(), ($n - 1));
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$lastval = '';
|
$lastval = '';
|
||||||
$retval = array();
|
$retval = array();
|
||||||
foreach ($segments as $seg)
|
foreach ($segments as $seg)
|
||||||
{
|
{
|
||||||
if ($i % 2)
|
if ($i % 2)
|
||||||
@ -465,7 +459,7 @@ class CI_URI {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$retval[$seg] = FALSE;
|
$retval[$seg] = NULL;
|
||||||
$lastval = $seg;
|
$lastval = $seg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,30 +472,31 @@ class CI_URI {
|
|||||||
{
|
{
|
||||||
if ( ! array_key_exists($val, $retval))
|
if ( ! array_key_exists($val, $retval))
|
||||||
{
|
{
|
||||||
$retval[$val] = FALSE;
|
$retval[$val] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cache the array for reuse
|
// Cache the array for reuse
|
||||||
$this->keyval[$n] = $retval;
|
isset($this->keyval[$which]) OR $this->keyval[$which] = array();
|
||||||
|
$this->keyval[$which][$n] = $retval;
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate a URI string from an associative array
|
* Assoc to URI
|
||||||
*
|
*
|
||||||
|
* Generates a URI string from an associative array.
|
||||||
*
|
*
|
||||||
* @access public
|
* @param array $array Input array of key/value pairs
|
||||||
* @param array an associative array of key/values
|
* @return string URI string
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
function assoc_to_uri($array)
|
public function assoc_to_uri($array)
|
||||||
{
|
{
|
||||||
$temp = array();
|
$temp = array();
|
||||||
foreach ((array)$array as $key => $val)
|
foreach ((array) $array as $key => $val)
|
||||||
{
|
{
|
||||||
$temp[] = $key;
|
$temp[] = $key;
|
||||||
$temp[] = $val;
|
$temp[] = $val;
|
||||||
@ -513,14 +508,15 @@ class CI_URI {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a URI Segment and add a trailing slash
|
* Slash segment
|
||||||
*
|
*
|
||||||
* @access public
|
* Fetches an URI segment with a slash.
|
||||||
* @param integer
|
*
|
||||||
* @param string
|
* @param int $n Index
|
||||||
|
* @param string $where Where to add the slash ('trailing' or 'leading')
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function slash_segment($n, $where = 'trailing')
|
public function slash_segment($n, $where = 'trailing')
|
||||||
{
|
{
|
||||||
return $this->_slash_segment($n, $where, 'segment');
|
return $this->_slash_segment($n, $where, 'segment');
|
||||||
}
|
}
|
||||||
@ -528,14 +524,15 @@ class CI_URI {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a URI Segment and add a trailing slash
|
* Slash routed segment
|
||||||
*
|
*
|
||||||
* @access public
|
* Fetches an URI routed segment with a slash.
|
||||||
* @param integer
|
*
|
||||||
* @param string
|
* @param int $n Index
|
||||||
|
* @param string $where Where to add the slash ('trailing' or 'leading')
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function slash_rsegment($n, $where = 'trailing')
|
public function slash_rsegment($n, $where = 'trailing')
|
||||||
{
|
{
|
||||||
return $this->_slash_segment($n, $where, 'rsegment');
|
return $this->_slash_segment($n, $where, 'rsegment');
|
||||||
}
|
}
|
||||||
@ -543,24 +540,27 @@ class CI_URI {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch a URI Segment and add a trailing slash - helper function
|
* Internal Slash segment
|
||||||
*
|
*
|
||||||
* @access private
|
* Fetches an URI Segment and adds a slash to it.
|
||||||
* @param integer
|
*
|
||||||
* @param string
|
* @used-by CI_URI::slash_segment()
|
||||||
* @param string
|
* @used-by CI_URI::slash_rsegment()
|
||||||
|
*
|
||||||
|
* @param int $n Index
|
||||||
|
* @param string $where Where to add the slash ('trailing' or 'leading')
|
||||||
|
* @param string $which Array name ('segment' or 'rsegment')
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _slash_segment($n, $where = 'trailing', $which = 'segment')
|
protected function _slash_segment($n, $where = 'trailing', $which = 'segment')
|
||||||
{
|
{
|
||||||
$leading = '/';
|
$leading = $trailing = '/';
|
||||||
$trailing = '/';
|
|
||||||
|
|
||||||
if ($where == 'trailing')
|
if ($where === 'trailing')
|
||||||
{
|
{
|
||||||
$leading = '';
|
$leading = '';
|
||||||
}
|
}
|
||||||
elseif ($where == 'leading')
|
elseif ($where === 'leading')
|
||||||
{
|
{
|
||||||
$trailing = '';
|
$trailing = '';
|
||||||
}
|
}
|
||||||
@ -573,10 +573,9 @@ class CI_URI {
|
|||||||
/**
|
/**
|
||||||
* Segment Array
|
* Segment Array
|
||||||
*
|
*
|
||||||
* @access public
|
* @return array CI_URI::$segments
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
function segment_array()
|
public function segment_array()
|
||||||
{
|
{
|
||||||
return $this->segments;
|
return $this->segments;
|
||||||
}
|
}
|
||||||
@ -586,10 +585,9 @@ class CI_URI {
|
|||||||
/**
|
/**
|
||||||
* Routed Segment Array
|
* Routed Segment Array
|
||||||
*
|
*
|
||||||
* @access public
|
* @return array CI_URI::$rsegments
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
function rsegment_array()
|
public function rsegment_array()
|
||||||
{
|
{
|
||||||
return $this->rsegments;
|
return $this->rsegments;
|
||||||
}
|
}
|
||||||
@ -599,10 +597,9 @@ class CI_URI {
|
|||||||
/**
|
/**
|
||||||
* Total number of segments
|
* Total number of segments
|
||||||
*
|
*
|
||||||
* @access public
|
* @return int
|
||||||
* @return integer
|
|
||||||
*/
|
*/
|
||||||
function total_segments()
|
public function total_segments()
|
||||||
{
|
{
|
||||||
return count($this->segments);
|
return count($this->segments);
|
||||||
}
|
}
|
||||||
@ -612,10 +609,9 @@ class CI_URI {
|
|||||||
/**
|
/**
|
||||||
* Total number of routed segments
|
* Total number of routed segments
|
||||||
*
|
*
|
||||||
* @access public
|
* @return int
|
||||||
* @return integer
|
|
||||||
*/
|
*/
|
||||||
function total_rsegments()
|
public function total_rsegments()
|
||||||
{
|
{
|
||||||
return count($this->rsegments);
|
return count($this->rsegments);
|
||||||
}
|
}
|
||||||
@ -623,32 +619,25 @@ class CI_URI {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the entire URI string
|
* Fetch URI string
|
||||||
*
|
*
|
||||||
* @access public
|
* @return string CI_URI::$uri_string
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
function uri_string()
|
public function uri_string()
|
||||||
{
|
{
|
||||||
return $this->uri_string;
|
return $this->uri_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the entire Re-routed URI string
|
* Fetch Re-routed URI string
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function ruri_string()
|
public function ruri_string()
|
||||||
{
|
{
|
||||||
return '/'.implode('/', $this->rsegment_array());
|
return ltrim(load_class('Router', 'core')->directory, '/').implode('/', $this->rsegments);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// END URI Class
|
|
||||||
|
|
||||||
/* End of file URI.php */
|
|
||||||
/* Location: ./system/core/URI.php */
|
|
149
system/core/Utf8.php
Executable file → Normal file
149
system/core/Utf8.php
Executable file → Normal file
@ -1,19 +1,41 @@
|
|||||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
<?php
|
||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.1.6 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* This content is released under the MIT License (MIT)
|
||||||
* @author ExpressionEngine Dev Team
|
*
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc.
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
* @license http://codeigniter.com/user_guide/license.html
|
*
|
||||||
* @link http://codeigniter.com
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* @since Version 2.0
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 2.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utf8 Class
|
* Utf8 Class
|
||||||
@ -23,52 +45,36 @@
|
|||||||
* @package CodeIgniter
|
* @package CodeIgniter
|
||||||
* @subpackage Libraries
|
* @subpackage Libraries
|
||||||
* @category UTF-8
|
* @category UTF-8
|
||||||
* @author ExpressionEngine Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/libraries/utf8.html
|
* @link https://codeigniter.com/user_guide/libraries/utf8.html
|
||||||
*/
|
*/
|
||||||
class CI_Utf8 {
|
class CI_Utf8 {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
* Determines if UTF-8 support is to be enabled
|
* Determines if UTF-8 support is to be enabled.
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
log_message('debug', "Utf8 Class Initialized");
|
|
||||||
|
|
||||||
global $CFG;
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
preg_match('/./u', 'é') === 1 // PCRE must support UTF-8
|
defined('PREG_BAD_UTF8_ERROR') // PCRE must support UTF-8
|
||||||
AND function_exists('iconv') // iconv must be installed
|
&& (ICONV_ENABLED === TRUE OR MB_ENABLED === TRUE) // iconv or mbstring must be installed
|
||||||
AND ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled
|
&& strtoupper(config_item('charset')) === 'UTF-8' // Application charset must be UTF-8
|
||||||
AND $CFG->item('charset') == 'UTF-8' // Application charset must be UTF-8
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
log_message('debug', "UTF-8 Support Enabled");
|
|
||||||
|
|
||||||
define('UTF8_ENABLED', TRUE);
|
define('UTF8_ENABLED', TRUE);
|
||||||
|
log_message('debug', 'UTF-8 Support Enabled');
|
||||||
// set internal encoding for multibyte string functions if necessary
|
|
||||||
// and set a flag so we don't have to repeatedly use extension_loaded()
|
|
||||||
// or function_exists()
|
|
||||||
if (extension_loaded('mbstring'))
|
|
||||||
{
|
|
||||||
define('MB_ENABLED', TRUE);
|
|
||||||
mb_internal_encoding('UTF-8');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
define('MB_ENABLED', FALSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_message('debug', "UTF-8 Support Disabled");
|
|
||||||
define('UTF8_ENABLED', FALSE);
|
define('UTF8_ENABLED', FALSE);
|
||||||
|
log_message('debug', 'UTF-8 Support Disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_message('info', 'Utf8 Class Initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -76,17 +82,23 @@ class CI_Utf8 {
|
|||||||
/**
|
/**
|
||||||
* Clean UTF-8 strings
|
* Clean UTF-8 strings
|
||||||
*
|
*
|
||||||
* Ensures strings are UTF-8
|
* Ensures strings contain only valid UTF-8 characters.
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $str String to clean
|
||||||
* @param string
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function clean_string($str)
|
public function clean_string($str)
|
||||||
{
|
{
|
||||||
if ($this->_is_ascii($str) === FALSE)
|
if ($this->is_ascii($str) === FALSE)
|
||||||
{
|
{
|
||||||
$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
|
if (MB_ENABLED)
|
||||||
|
{
|
||||||
|
$str = mb_convert_encoding($str, 'UTF-8', 'UTF-8');
|
||||||
|
}
|
||||||
|
elseif (ICONV_ENABLED)
|
||||||
|
{
|
||||||
|
$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $str;
|
return $str;
|
||||||
@ -99,13 +111,12 @@ class CI_Utf8 {
|
|||||||
*
|
*
|
||||||
* Removes all ASCII control characters except horizontal tabs,
|
* Removes all ASCII control characters except horizontal tabs,
|
||||||
* line feeds, and carriage returns, as all others can cause
|
* line feeds, and carriage returns, as all others can cause
|
||||||
* problems in XML
|
* problems in XML.
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $str String to clean
|
||||||
* @param string
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function safe_ascii_for_xml($str)
|
public function safe_ascii_for_xml($str)
|
||||||
{
|
{
|
||||||
return remove_invisible_characters($str, FALSE);
|
return remove_invisible_characters($str, FALSE);
|
||||||
}
|
}
|
||||||
@ -115,29 +126,24 @@ class CI_Utf8 {
|
|||||||
/**
|
/**
|
||||||
* Convert to UTF-8
|
* Convert to UTF-8
|
||||||
*
|
*
|
||||||
* Attempts to convert a string to UTF-8
|
* Attempts to convert a string to UTF-8.
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $str Input string
|
||||||
* @param string
|
* @param string $encoding Input encoding
|
||||||
* @param string - input encoding
|
* @return string $str encoded in UTF-8 or FALSE on failure
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
function convert_to_utf8($str, $encoding)
|
public function convert_to_utf8($str, $encoding)
|
||||||
{
|
{
|
||||||
if (function_exists('iconv'))
|
if (MB_ENABLED)
|
||||||
{
|
{
|
||||||
$str = @iconv($encoding, 'UTF-8', $str);
|
return mb_convert_encoding($str, 'UTF-8', $encoding);
|
||||||
}
|
}
|
||||||
elseif (function_exists('mb_convert_encoding'))
|
elseif (ICONV_ENABLED)
|
||||||
{
|
{
|
||||||
$str = @mb_convert_encoding($str, 'UTF-8', $encoding);
|
return @iconv($encoding, 'UTF-8', $str);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $str;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -145,21 +151,14 @@ class CI_Utf8 {
|
|||||||
/**
|
/**
|
||||||
* Is ASCII?
|
* Is ASCII?
|
||||||
*
|
*
|
||||||
* Tests if a string is standard 7-bit ASCII or not
|
* Tests if a string is standard 7-bit ASCII or not.
|
||||||
*
|
*
|
||||||
* @access public
|
* @param string $str String to check
|
||||||
* @param string
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function _is_ascii($str)
|
public function is_ascii($str)
|
||||||
{
|
{
|
||||||
return (preg_match('/[^\x00-\x7F]/S', $str) == 0);
|
return (preg_match('/[^\x00-\x7F]/S', $str) === 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// End Utf8 Class
|
|
||||||
|
|
||||||
/* End of file Utf8.php */
|
|
||||||
/* Location: ./system/core/Utf8.php */
|
|
254
system/core/compat/hash.php
Normal file
254
system/core/compat/hash.php
Normal file
@ -0,0 +1,254 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP
|
||||||
|
*
|
||||||
|
* This content is released under the MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 3.0.0
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP ext/hash compatibility package
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage CodeIgniter
|
||||||
|
* @category Compatibility
|
||||||
|
* @author Andrey Andreev
|
||||||
|
* @link https://codeigniter.com/user_guide/
|
||||||
|
* @link http://php.net/hash
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if (is_php('5.6'))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( ! function_exists('hash_equals'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* hash_equals()
|
||||||
|
*
|
||||||
|
* @link http://php.net/hash_equals
|
||||||
|
* @param string $known_string
|
||||||
|
* @param string $user_string
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function hash_equals($known_string, $user_string)
|
||||||
|
{
|
||||||
|
if ( ! is_string($known_string))
|
||||||
|
{
|
||||||
|
trigger_error('hash_equals(): Expected known_string to be a string, '.strtolower(gettype($known_string)).' given', E_USER_WARNING);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
elseif ( ! is_string($user_string))
|
||||||
|
{
|
||||||
|
trigger_error('hash_equals(): Expected user_string to be a string, '.strtolower(gettype($user_string)).' given', E_USER_WARNING);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
elseif (($length = strlen($known_string)) !== strlen($user_string))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$diff = 0;
|
||||||
|
for ($i = 0; $i < $length; $i++)
|
||||||
|
{
|
||||||
|
$diff |= ord($known_string[$i]) ^ ord($user_string[$i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($diff === 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if (is_php('5.5'))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( ! function_exists('hash_pbkdf2'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* hash_pbkdf2()
|
||||||
|
*
|
||||||
|
* @link http://php.net/hash_pbkdf2
|
||||||
|
* @param string $algo
|
||||||
|
* @param string $password
|
||||||
|
* @param string $salt
|
||||||
|
* @param int $iterations
|
||||||
|
* @param int $length
|
||||||
|
* @param bool $raw_output
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function hash_pbkdf2($algo, $password, $salt, $iterations, $length = 0, $raw_output = FALSE)
|
||||||
|
{
|
||||||
|
if ( ! in_array(strtolower($algo), hash_algos(), TRUE))
|
||||||
|
{
|
||||||
|
trigger_error('hash_pbkdf2(): Unknown hashing algorithm: '.$algo, E_USER_WARNING);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($type = gettype($iterations)) !== 'integer')
|
||||||
|
{
|
||||||
|
if ($type === 'object' && method_exists($iterations, '__toString'))
|
||||||
|
{
|
||||||
|
$iterations = (string) $iterations;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_string($iterations) && is_numeric($iterations))
|
||||||
|
{
|
||||||
|
$iterations = (int) $iterations;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
trigger_error('hash_pbkdf2() expects parameter 4 to be long, '.$type.' given', E_USER_WARNING);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($iterations < 1)
|
||||||
|
{
|
||||||
|
trigger_error('hash_pbkdf2(): Iterations must be a positive integer: '.$iterations, E_USER_WARNING);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($type = gettype($length)) !== 'integer')
|
||||||
|
{
|
||||||
|
if ($type === 'object' && method_exists($length, '__toString'))
|
||||||
|
{
|
||||||
|
$length = (string) $length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_string($length) && is_numeric($length))
|
||||||
|
{
|
||||||
|
$length = (int) $length;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
trigger_error('hash_pbkdf2() expects parameter 5 to be long, '.$type.' given', E_USER_WARNING);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($length < 0)
|
||||||
|
{
|
||||||
|
trigger_error('hash_pbkdf2(): Length must be greater than or equal to 0: '.$length, E_USER_WARNING);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$hash_length = defined('MB_OVERLOAD_STRING')
|
||||||
|
? mb_strlen(hash($algo, NULL, TRUE), '8bit')
|
||||||
|
: strlen(hash($algo, NULL, TRUE));
|
||||||
|
empty($length) && $length = $hash_length;
|
||||||
|
|
||||||
|
// Pre-hash password inputs longer than the algorithm's block size
|
||||||
|
// (i.e. prepare HMAC key) to mitigate potential DoS attacks.
|
||||||
|
static $block_sizes;
|
||||||
|
empty($block_sizes) && $block_sizes = array(
|
||||||
|
'gost' => 32,
|
||||||
|
'haval128,3' => 128,
|
||||||
|
'haval160,3' => 128,
|
||||||
|
'haval192,3' => 128,
|
||||||
|
'haval224,3' => 128,
|
||||||
|
'haval256,3' => 128,
|
||||||
|
'haval128,4' => 128,
|
||||||
|
'haval160,4' => 128,
|
||||||
|
'haval192,4' => 128,
|
||||||
|
'haval224,4' => 128,
|
||||||
|
'haval256,4' => 128,
|
||||||
|
'haval128,5' => 128,
|
||||||
|
'haval160,5' => 128,
|
||||||
|
'haval192,5' => 128,
|
||||||
|
'haval224,5' => 128,
|
||||||
|
'haval256,5' => 128,
|
||||||
|
'md2' => 16,
|
||||||
|
'md4' => 64,
|
||||||
|
'md5' => 64,
|
||||||
|
'ripemd128' => 64,
|
||||||
|
'ripemd160' => 64,
|
||||||
|
'ripemd256' => 64,
|
||||||
|
'ripemd320' => 64,
|
||||||
|
'salsa10' => 64,
|
||||||
|
'salsa20' => 64,
|
||||||
|
'sha1' => 64,
|
||||||
|
'sha224' => 64,
|
||||||
|
'sha256' => 64,
|
||||||
|
'sha384' => 128,
|
||||||
|
'sha512' => 128,
|
||||||
|
'snefru' => 32,
|
||||||
|
'snefru256' => 32,
|
||||||
|
'tiger128,3' => 64,
|
||||||
|
'tiger160,3' => 64,
|
||||||
|
'tiger192,3' => 64,
|
||||||
|
'tiger128,4' => 64,
|
||||||
|
'tiger160,4' => 64,
|
||||||
|
'tiger192,4' => 64,
|
||||||
|
'whirlpool' => 64
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isset($block_sizes[$algo], $password[$block_sizes[$algo]]))
|
||||||
|
{
|
||||||
|
$password = hash($algo, $password, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
$hash = '';
|
||||||
|
// Note: Blocks are NOT 0-indexed
|
||||||
|
for ($bc = (int) ceil($length / $hash_length), $bi = 1; $bi <= $bc; $bi++)
|
||||||
|
{
|
||||||
|
$key = $derived_key = hash_hmac($algo, $salt.pack('N', $bi), $password, TRUE);
|
||||||
|
for ($i = 1; $i < $iterations; $i++)
|
||||||
|
{
|
||||||
|
$derived_key ^= $key = hash_hmac($algo, $key, $password, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
$hash .= $derived_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is not RFC-compatible, but we're aiming for natural PHP compatibility
|
||||||
|
if ( ! $raw_output)
|
||||||
|
{
|
||||||
|
$hash = bin2hex($hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
return defined('MB_OVERLOAD_STRING')
|
||||||
|
? mb_substr($hash, 0, $length, '8bit')
|
||||||
|
: substr($hash, 0, $length);
|
||||||
|
}
|
||||||
|
}
|
3
system/libraries/javascript/index.html → system/core/compat/index.html
Executable file → Normal file
3
system/libraries/javascript/index.html → system/core/compat/index.html
Executable file → Normal file
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>403 Forbidden</title>
|
<title>403 Forbidden</title>
|
||||||
@ -7,4 +8,4 @@
|
|||||||
<p>Directory access is forbidden.</p>
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
149
system/core/compat/mbstring.php
Normal file
149
system/core/compat/mbstring.php
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP
|
||||||
|
*
|
||||||
|
* This content is released under the MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 3.0.0
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP ext/mbstring compatibility package
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage CodeIgniter
|
||||||
|
* @category Compatibility
|
||||||
|
* @author Andrey Andreev
|
||||||
|
* @link https://codeigniter.com/user_guide/
|
||||||
|
* @link http://php.net/mbstring
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if (MB_ENABLED === TRUE)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( ! function_exists('mb_strlen'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* mb_strlen()
|
||||||
|
*
|
||||||
|
* WARNING: This function WILL fall-back to strlen()
|
||||||
|
* if iconv is not available!
|
||||||
|
*
|
||||||
|
* @link http://php.net/mb_strlen
|
||||||
|
* @param string $str
|
||||||
|
* @param string $encoding
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function mb_strlen($str, $encoding = NULL)
|
||||||
|
{
|
||||||
|
if (ICONV_ENABLED === TRUE)
|
||||||
|
{
|
||||||
|
return iconv_strlen($str, isset($encoding) ? $encoding : config_item('charset'));
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message('debug', 'Compatibility (mbstring): iconv_strlen() is not available, falling back to strlen().');
|
||||||
|
return strlen($str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( ! function_exists('mb_strpos'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* mb_strpos()
|
||||||
|
*
|
||||||
|
* WARNING: This function WILL fall-back to strpos()
|
||||||
|
* if iconv is not available!
|
||||||
|
*
|
||||||
|
* @link http://php.net/mb_strpos
|
||||||
|
* @param string $haystack
|
||||||
|
* @param string $needle
|
||||||
|
* @param int $offset
|
||||||
|
* @param string $encoding
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function mb_strpos($haystack, $needle, $offset = 0, $encoding = NULL)
|
||||||
|
{
|
||||||
|
if (ICONV_ENABLED === TRUE)
|
||||||
|
{
|
||||||
|
return iconv_strpos($haystack, $needle, $offset, isset($encoding) ? $encoding : config_item('charset'));
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message('debug', 'Compatibility (mbstring): iconv_strpos() is not available, falling back to strpos().');
|
||||||
|
return strpos($haystack, $needle, $offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( ! function_exists('mb_substr'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* mb_substr()
|
||||||
|
*
|
||||||
|
* WARNING: This function WILL fall-back to substr()
|
||||||
|
* if iconv is not available.
|
||||||
|
*
|
||||||
|
* @link http://php.net/mb_substr
|
||||||
|
* @param string $str
|
||||||
|
* @param int $start
|
||||||
|
* @param int $length
|
||||||
|
* @param string $encoding
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function mb_substr($str, $start, $length = NULL, $encoding = NULL)
|
||||||
|
{
|
||||||
|
if (ICONV_ENABLED === TRUE)
|
||||||
|
{
|
||||||
|
isset($encoding) OR $encoding = config_item('charset');
|
||||||
|
return iconv_substr(
|
||||||
|
$str,
|
||||||
|
$start,
|
||||||
|
isset($length) ? $length : iconv_strlen($str, $encoding), // NULL doesn't work
|
||||||
|
$encoding
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message('debug', 'Compatibility (mbstring): iconv_substr() is not available, falling back to substr().');
|
||||||
|
return isset($length)
|
||||||
|
? substr($str, $start, $length)
|
||||||
|
: substr($str, $start);
|
||||||
|
}
|
||||||
|
}
|
251
system/core/compat/password.php
Normal file
251
system/core/compat/password.php
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP
|
||||||
|
*
|
||||||
|
* This content is released under the MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 3.0.0
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP ext/standard/password compatibility package
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage CodeIgniter
|
||||||
|
* @category Compatibility
|
||||||
|
* @author Andrey Andreev
|
||||||
|
* @link https://codeigniter.com/user_guide/
|
||||||
|
* @link http://php.net/password
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if (is_php('5.5') OR ! defined('CRYPT_BLOWFISH') OR CRYPT_BLOWFISH !== 1 OR defined('HHVM_VERSION'))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
defined('PASSWORD_BCRYPT') OR define('PASSWORD_BCRYPT', 1);
|
||||||
|
defined('PASSWORD_DEFAULT') OR define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( ! function_exists('password_get_info'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* password_get_info()
|
||||||
|
*
|
||||||
|
* @link http://php.net/password_get_info
|
||||||
|
* @param string $hash
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function password_get_info($hash)
|
||||||
|
{
|
||||||
|
return (strlen($hash) < 60 OR sscanf($hash, '$2y$%d', $hash) !== 1)
|
||||||
|
? array('algo' => 0, 'algoName' => 'unknown', 'options' => array())
|
||||||
|
: array('algo' => 1, 'algoName' => 'bcrypt', 'options' => array('cost' => $hash));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( ! function_exists('password_hash'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* password_hash()
|
||||||
|
*
|
||||||
|
* @link http://php.net/password_hash
|
||||||
|
* @param string $password
|
||||||
|
* @param int $algo
|
||||||
|
* @param array $options
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function password_hash($password, $algo, array $options = array())
|
||||||
|
{
|
||||||
|
static $func_overload;
|
||||||
|
isset($func_overload) OR $func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
|
||||||
|
|
||||||
|
if ($algo !== 1)
|
||||||
|
{
|
||||||
|
trigger_error('password_hash(): Unknown hashing algorithm: '.(int) $algo, E_USER_WARNING);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['cost']) && ($options['cost'] < 4 OR $options['cost'] > 31))
|
||||||
|
{
|
||||||
|
trigger_error('password_hash(): Invalid bcrypt cost parameter specified: '.(int) $options['cost'], E_USER_WARNING);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['salt']) && ($saltlen = ($func_overload ? mb_strlen($options['salt'], '8bit') : strlen($options['salt']))) < 22)
|
||||||
|
{
|
||||||
|
trigger_error('password_hash(): Provided salt is too short: '.$saltlen.' expecting 22', E_USER_WARNING);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
elseif ( ! isset($options['salt']))
|
||||||
|
{
|
||||||
|
if (function_exists('random_bytes'))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$options['salt'] = random_bytes(16);
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
log_message('error', 'compat/password: Error while trying to use random_bytes(): '.$e->getMessage());
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif (defined('MCRYPT_DEV_URANDOM'))
|
||||||
|
{
|
||||||
|
$options['salt'] = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM);
|
||||||
|
}
|
||||||
|
elseif (DIRECTORY_SEPARATOR === '/' && (is_readable($dev = '/dev/arandom') OR is_readable($dev = '/dev/urandom')))
|
||||||
|
{
|
||||||
|
if (($fp = fopen($dev, 'rb')) === FALSE)
|
||||||
|
{
|
||||||
|
log_message('error', 'compat/password: Unable to open '.$dev.' for reading.');
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try not to waste entropy ...
|
||||||
|
is_php('5.4') && stream_set_chunk_size($fp, 16);
|
||||||
|
|
||||||
|
$options['salt'] = '';
|
||||||
|
for ($read = 0; $read < 16; $read = ($func_overload) ? mb_strlen($options['salt'], '8bit') : strlen($options['salt']))
|
||||||
|
{
|
||||||
|
if (($read = fread($fp, 16 - $read)) === FALSE)
|
||||||
|
{
|
||||||
|
log_message('error', 'compat/password: Error while reading from '.$dev.'.');
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
$options['salt'] .= $read;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
}
|
||||||
|
elseif (function_exists('openssl_random_pseudo_bytes'))
|
||||||
|
{
|
||||||
|
$is_secure = NULL;
|
||||||
|
$options['salt'] = openssl_random_pseudo_bytes(16, $is_secure);
|
||||||
|
if ($is_secure !== TRUE)
|
||||||
|
{
|
||||||
|
log_message('error', 'compat/password: openssl_random_pseudo_bytes() set the $cryto_strong flag to FALSE');
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log_message('error', 'compat/password: No CSPRNG available.');
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$options['salt'] = str_replace('+', '.', rtrim(base64_encode($options['salt']), '='));
|
||||||
|
}
|
||||||
|
elseif ( ! preg_match('#^[a-zA-Z0-9./]+$#D', $options['salt']))
|
||||||
|
{
|
||||||
|
$options['salt'] = str_replace('+', '.', rtrim(base64_encode($options['salt']), '='));
|
||||||
|
}
|
||||||
|
|
||||||
|
isset($options['cost']) OR $options['cost'] = 10;
|
||||||
|
|
||||||
|
return (strlen($password = crypt($password, sprintf('$2y$%02d$%s', $options['cost'], $options['salt']))) === 60)
|
||||||
|
? $password
|
||||||
|
: FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( ! function_exists('password_needs_rehash'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* password_needs_rehash()
|
||||||
|
*
|
||||||
|
* @link http://php.net/password_needs_rehash
|
||||||
|
* @param string $hash
|
||||||
|
* @param int $algo
|
||||||
|
* @param array $options
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function password_needs_rehash($hash, $algo, array $options = array())
|
||||||
|
{
|
||||||
|
$info = password_get_info($hash);
|
||||||
|
|
||||||
|
if ($algo !== $info['algo'])
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
elseif ($algo === 1)
|
||||||
|
{
|
||||||
|
$options['cost'] = isset($options['cost']) ? (int) $options['cost'] : 10;
|
||||||
|
return ($info['options']['cost'] !== $options['cost']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Odd at first glance, but according to a comment in PHP's own unit tests,
|
||||||
|
// because it is an unknown algorithm - it's valid and therefore doesn't
|
||||||
|
// need rehashing.
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( ! function_exists('password_verify'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* password_verify()
|
||||||
|
*
|
||||||
|
* @link http://php.net/password_verify
|
||||||
|
* @param string $password
|
||||||
|
* @param string $hash
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function password_verify($password, $hash)
|
||||||
|
{
|
||||||
|
if (strlen($hash) !== 60 OR strlen($password = crypt($password, $hash)) !== 60)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$compare = 0;
|
||||||
|
for ($i = 0; $i < 60; $i++)
|
||||||
|
{
|
||||||
|
$compare |= (ord($password[$i]) ^ ord($hash[$i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($compare === 0);
|
||||||
|
}
|
||||||
|
}
|
182
system/core/compat/standard.php
Normal file
182
system/core/compat/standard.php
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP
|
||||||
|
*
|
||||||
|
* This content is released under the MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 3.0.0
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP ext/standard compatibility package
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage CodeIgniter
|
||||||
|
* @category Compatibility
|
||||||
|
* @author Andrey Andreev
|
||||||
|
* @link https://codeigniter.com/user_guide/
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if (is_php('5.5'))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( ! function_exists('array_column'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* array_column()
|
||||||
|
*
|
||||||
|
* @link http://php.net/array_column
|
||||||
|
* @param array $array
|
||||||
|
* @param mixed $column_key
|
||||||
|
* @param mixed $index_key
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function array_column(array $array, $column_key, $index_key = NULL)
|
||||||
|
{
|
||||||
|
if ( ! in_array($type = gettype($column_key), array('integer', 'string', 'NULL'), TRUE))
|
||||||
|
{
|
||||||
|
if ($type === 'double')
|
||||||
|
{
|
||||||
|
$column_key = (int) $column_key;
|
||||||
|
}
|
||||||
|
elseif ($type === 'object' && method_exists($column_key, '__toString'))
|
||||||
|
{
|
||||||
|
$column_key = (string) $column_key;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! in_array($type = gettype($index_key), array('integer', 'string', 'NULL'), TRUE))
|
||||||
|
{
|
||||||
|
if ($type === 'double')
|
||||||
|
{
|
||||||
|
$index_key = (int) $index_key;
|
||||||
|
}
|
||||||
|
elseif ($type === 'object' && method_exists($index_key, '__toString'))
|
||||||
|
{
|
||||||
|
$index_key = (string) $index_key;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
foreach ($array as &$a)
|
||||||
|
{
|
||||||
|
if ($column_key === NULL)
|
||||||
|
{
|
||||||
|
$value = $a;
|
||||||
|
}
|
||||||
|
elseif (is_array($a) && array_key_exists($column_key, $a))
|
||||||
|
{
|
||||||
|
$value = $a[$column_key];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($index_key === NULL OR ! array_key_exists($index_key, $a))
|
||||||
|
{
|
||||||
|
$result[] = $value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result[$a[$index_key]] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if (is_php('5.4'))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if ( ! function_exists('hex2bin'))
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* hex2bin()
|
||||||
|
*
|
||||||
|
* @link http://php.net/hex2bin
|
||||||
|
* @param string $data
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function hex2bin($data)
|
||||||
|
{
|
||||||
|
if (in_array($type = gettype($data), array('array', 'double', 'object', 'resource'), TRUE))
|
||||||
|
{
|
||||||
|
if ($type === 'object' && method_exists($data, '__toString'))
|
||||||
|
{
|
||||||
|
$data = (string) $data;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
trigger_error('hex2bin() expects parameter 1 to be string, '.$type.' given', E_USER_WARNING);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($data) % 2 !== 0)
|
||||||
|
{
|
||||||
|
trigger_error('Hexadecimal input string must have an even length', E_USER_WARNING);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
elseif ( ! preg_match('/^[0-9a-f]*$/i', $data))
|
||||||
|
{
|
||||||
|
trigger_error('Input string must be hexadecimal string', E_USER_WARNING);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pack('H*', $data);
|
||||||
|
}
|
||||||
|
}
|
3
system/core/index.html
Executable file → Normal file
3
system/core/index.html
Executable file → Normal file
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>403 Forbidden</title>
|
<title>403 Forbidden</title>
|
||||||
@ -7,4 +8,4 @@
|
|||||||
<p>Directory access is forbidden.</p>
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
79
system/database/DB.php
Executable file → Normal file
79
system/database/DB.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*
|
*
|
||||||
* @param string|string[] $params
|
* @param string|string[] $params
|
||||||
* @param bool $query_builder_override
|
* @param bool $query_builder_override
|
||||||
@ -50,18 +61,23 @@ function &DB($params = '', $query_builder_override = NULL)
|
|||||||
}
|
}
|
||||||
|
|
||||||
include($file_path);
|
include($file_path);
|
||||||
// Make packages contain database config files
|
|
||||||
foreach (get_instance()->load->get_package_paths() as $path)
|
// Make packages contain database config files,
|
||||||
|
// given that the controller instance already exists
|
||||||
|
if (class_exists('CI_Controller', FALSE))
|
||||||
{
|
{
|
||||||
if ($path !== APPPATH)
|
foreach (get_instance()->load->get_package_paths() as $path)
|
||||||
{
|
{
|
||||||
if (file_exists($file_path = $path.'config/'.ENVIRONMENT.'/database.php'))
|
if ($path !== APPPATH)
|
||||||
{
|
{
|
||||||
include($file_path);
|
if (file_exists($file_path = $path.'config/'.ENVIRONMENT.'/database.php'))
|
||||||
}
|
{
|
||||||
elseif (file_exists($file_path = $path.'config/database.php'))
|
include($file_path);
|
||||||
{
|
}
|
||||||
include($file_path);
|
elseif (file_exists($file_path = $path.'config/database.php'))
|
||||||
|
{
|
||||||
|
include($file_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +135,7 @@ function &DB($params = '', $query_builder_override = NULL)
|
|||||||
{
|
{
|
||||||
if (is_string($val) && in_array(strtoupper($val), array('TRUE', 'FALSE', 'NULL')))
|
if (is_string($val) && in_array(strtoupper($val), array('TRUE', 'FALSE', 'NULL')))
|
||||||
{
|
{
|
||||||
$val = var_export($val);
|
$val = var_export($val, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
$params[$key] = $val;
|
$params[$key] = $val;
|
||||||
@ -197,13 +213,6 @@ function &DB($params = '', $query_builder_override = NULL)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($DB->autoinit === TRUE)
|
$DB->initialize();
|
||||||
{
|
|
||||||
$DB->initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $DB;
|
return $DB;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file DB.php */
|
|
||||||
/* Location: ./system/database/DB.php */
|
|
61
system/database/DB_cache.php
Executable file → Normal file
61
system/database/DB_cache.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_Cache {
|
class CI_DB_Cache {
|
||||||
|
|
||||||
@ -132,7 +143,7 @@ class CI_DB_Cache {
|
|||||||
$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
|
$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
|
||||||
$filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql);
|
$filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql);
|
||||||
|
|
||||||
if (FALSE === ($cachedata = @file_get_contents($filepath)))
|
if ( ! is_file($filepath) OR FALSE === ($cachedata = file_get_contents($filepath)))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -156,14 +167,9 @@ class CI_DB_Cache {
|
|||||||
$dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';
|
$dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';
|
||||||
$filename = md5($sql);
|
$filename = md5($sql);
|
||||||
|
|
||||||
if ( ! is_dir($dir_path))
|
if ( ! is_dir($dir_path) && ! @mkdir($dir_path, 0750))
|
||||||
{
|
{
|
||||||
if ( ! @mkdir($dir_path, 0777))
|
return FALSE;
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@chmod($dir_path, 0777);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (write_file($dir_path.$filename, serialize($object)) === FALSE)
|
if (write_file($dir_path.$filename, serialize($object)) === FALSE)
|
||||||
@ -171,7 +177,7 @@ class CI_DB_Cache {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@chmod($dir_path.$filename, 0666);
|
chmod($dir_path.$filename, 0640);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,6 +219,3 @@ class CI_DB_Cache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file DB_cache.php */
|
|
||||||
/* Location: ./system/database/DB_cache.php */
|
|
353
system/database/DB_driver.php
Executable file → Normal file
353
system/database/DB_driver.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -37,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
abstract class CI_DB_driver {
|
abstract class CI_DB_driver {
|
||||||
|
|
||||||
@ -112,15 +123,6 @@ abstract class CI_DB_driver {
|
|||||||
*/
|
*/
|
||||||
public $dbcollat = 'utf8_general_ci';
|
public $dbcollat = 'utf8_general_ci';
|
||||||
|
|
||||||
/**
|
|
||||||
* Auto-init flag
|
|
||||||
*
|
|
||||||
* Whether to automatically initialize the DB connection.
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
public $autoinit = TRUE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encryption flag/data
|
* Encryption flag/data
|
||||||
*
|
*
|
||||||
@ -140,7 +142,7 @@ abstract class CI_DB_driver {
|
|||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $port = '';
|
public $port = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persistent connection flag
|
* Persistent connection flag
|
||||||
@ -370,7 +372,7 @@ abstract class CI_DB_driver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log_message('debug', 'Database Driver Class Initialized');
|
log_message('info', 'Database Driver Class Initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -444,10 +446,24 @@ abstract class CI_DB_driver {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DB connect
|
||||||
|
*
|
||||||
|
* This is just a dummy method that all drivers will override.
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function db_connect()
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persistent database connection
|
* Persistent database connection
|
||||||
*
|
*
|
||||||
* @return resource
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function db_pconnect()
|
public function db_pconnect()
|
||||||
{
|
{
|
||||||
@ -465,7 +481,7 @@ abstract class CI_DB_driver {
|
|||||||
* This is just a dummy method to allow drivers without such
|
* This is just a dummy method to allow drivers without such
|
||||||
* functionality to not declare it, while others will override it.
|
* functionality to not declare it, while others will override it.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function reconnect()
|
public function reconnect()
|
||||||
{
|
{
|
||||||
@ -479,7 +495,7 @@ abstract class CI_DB_driver {
|
|||||||
* This is just a dummy method to allow drivers without such
|
* This is just a dummy method to allow drivers without such
|
||||||
* functionality to not declare it, while others will override it.
|
* functionality to not declare it, while others will override it.
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function db_select()
|
public function db_select()
|
||||||
{
|
{
|
||||||
@ -488,6 +504,18 @@ abstract class CI_DB_driver {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Last error
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function error()
|
||||||
|
{
|
||||||
|
return array('code' => NULL, 'message' => NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set client character set
|
* Set client character set
|
||||||
*
|
*
|
||||||
@ -631,7 +659,10 @@ abstract class CI_DB_driver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This will trigger a rollback if transactions are being used
|
// This will trigger a rollback if transactions are being used
|
||||||
$this->_trans_status = FALSE;
|
if ($this->_trans_depth !== 0)
|
||||||
|
{
|
||||||
|
$this->_trans_status = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
// Grab the error now, as we might run some additional queries before displaying the error
|
// Grab the error now, as we might run some additional queries before displaying the error
|
||||||
$error = $this->error();
|
$error = $this->error();
|
||||||
@ -645,13 +676,15 @@ abstract class CI_DB_driver {
|
|||||||
// if transactions are enabled. If we don't call this here
|
// if transactions are enabled. If we don't call this here
|
||||||
// the error message will trigger an exit, causing the
|
// the error message will trigger an exit, causing the
|
||||||
// transactions to remain in limbo.
|
// transactions to remain in limbo.
|
||||||
if ($this->_trans_depth !== 0)
|
while ($this->_trans_depth !== 0)
|
||||||
{
|
{
|
||||||
do
|
$trans_depth = $this->_trans_depth;
|
||||||
|
$this->trans_complete();
|
||||||
|
if ($trans_depth === $this->_trans_depth)
|
||||||
{
|
{
|
||||||
$this->trans_complete();
|
log_message('error', 'Database: Failure during an automated transaction commit/rollback!');
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
while ($this->_trans_depth !== 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display errors
|
// Display errors
|
||||||
@ -749,7 +782,10 @@ abstract class CI_DB_driver {
|
|||||||
{
|
{
|
||||||
if ( ! $this->conn_id)
|
if ( ! $this->conn_id)
|
||||||
{
|
{
|
||||||
$this->initialize();
|
if ( ! $this->initialize())
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->_execute($sql);
|
return $this->_execute($sql);
|
||||||
@ -772,10 +808,13 @@ abstract class CI_DB_driver {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/disable Transaction Strict Mode
|
* Enable/disable Transaction Strict Mode
|
||||||
|
*
|
||||||
* When strict mode is enabled, if you are running multiple groups of
|
* When strict mode is enabled, if you are running multiple groups of
|
||||||
* transactions, if one group fails all groups will be rolled back.
|
* transactions, if one group fails all subsequent groups will be
|
||||||
* If strict mode is disabled, each group is treated autonomously, meaning
|
* rolled back.
|
||||||
* a failure of one group will not affect any others
|
*
|
||||||
|
* If strict mode is disabled, each group is treated autonomously,
|
||||||
|
* meaning a failure of one group will not affect any others
|
||||||
*
|
*
|
||||||
* @param bool $mode = TRUE
|
* @param bool $mode = TRUE
|
||||||
* @return void
|
* @return void
|
||||||
@ -791,7 +830,7 @@ abstract class CI_DB_driver {
|
|||||||
* Start Transaction
|
* Start Transaction
|
||||||
*
|
*
|
||||||
* @param bool $test_mode = FALSE
|
* @param bool $test_mode = FALSE
|
||||||
* @return void
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_start($test_mode = FALSE)
|
public function trans_start($test_mode = FALSE)
|
||||||
{
|
{
|
||||||
@ -800,15 +839,7 @@ abstract class CI_DB_driver {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
return $this->trans_begin($test_mode);
|
||||||
if ($this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
$this->_trans_depth += 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->trans_begin($test_mode);
|
|
||||||
$this->_trans_depth += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -825,25 +856,14 @@ abstract class CI_DB_driver {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ($this->_trans_depth > 1)
|
|
||||||
{
|
|
||||||
$this->_trans_depth -= 1;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->_trans_depth = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The query() function will set this flag to FALSE in the event that a query failed
|
// The query() function will set this flag to FALSE in the event that a query failed
|
||||||
if ($this->_trans_status === FALSE OR $this->_trans_failure === TRUE)
|
if ($this->_trans_status === FALSE OR $this->_trans_failure === TRUE)
|
||||||
{
|
{
|
||||||
$this->trans_rollback();
|
$this->trans_rollback();
|
||||||
|
|
||||||
// If we are NOT running in strict mode, we will reset
|
// If we are NOT running in strict mode, we will reset
|
||||||
// the _trans_status flag so that subsequent groups of transactions
|
// the _trans_status flag so that subsequent groups of
|
||||||
// will be permitted.
|
// transactions will be permitted.
|
||||||
if ($this->trans_strict === FALSE)
|
if ($this->trans_strict === FALSE)
|
||||||
{
|
{
|
||||||
$this->_trans_status = TRUE;
|
$this->_trans_status = TRUE;
|
||||||
@ -853,8 +873,7 @@ abstract class CI_DB_driver {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->trans_commit();
|
return $this->trans_commit();
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -871,6 +890,88 @@ abstract class CI_DB_driver {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begin Transaction
|
||||||
|
*
|
||||||
|
* @param bool $test_mode
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function trans_begin($test_mode = FALSE)
|
||||||
|
{
|
||||||
|
if ( ! $this->trans_enabled)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||||
|
elseif ($this->_trans_depth > 0)
|
||||||
|
{
|
||||||
|
$this->_trans_depth++;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset the transaction failure flag.
|
||||||
|
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
||||||
|
// even if the queries produce a successful result.
|
||||||
|
$this->_trans_failure = ($test_mode === TRUE);
|
||||||
|
|
||||||
|
if ($this->_trans_begin())
|
||||||
|
{
|
||||||
|
$this->_trans_status = TRUE;
|
||||||
|
$this->_trans_depth++;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit Transaction
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function trans_commit()
|
||||||
|
{
|
||||||
|
if ( ! $this->trans_enabled OR $this->_trans_depth === 0)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||||
|
elseif ($this->_trans_depth > 1 OR $this->_trans_commit())
|
||||||
|
{
|
||||||
|
$this->_trans_depth--;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rollback Transaction
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function trans_rollback()
|
||||||
|
{
|
||||||
|
if ( ! $this->trans_enabled OR $this->_trans_depth === 0)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
// When transactions are nested we only begin/commit/rollback the outermost ones
|
||||||
|
elseif ($this->_trans_depth > 1 OR $this->_trans_rollback())
|
||||||
|
{
|
||||||
|
$this->_trans_depth--;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile Bindings
|
* Compile Bindings
|
||||||
*
|
*
|
||||||
@ -880,7 +981,7 @@ abstract class CI_DB_driver {
|
|||||||
*/
|
*/
|
||||||
public function compile_binds($sql, $binds)
|
public function compile_binds($sql, $binds)
|
||||||
{
|
{
|
||||||
if (empty($binds) OR empty($this->bind_marker) OR strpos($sql, $this->bind_marker) === FALSE)
|
if (empty($this->bind_marker) OR strpos($sql, $this->bind_marker) === FALSE)
|
||||||
{
|
{
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
@ -900,7 +1001,7 @@ abstract class CI_DB_driver {
|
|||||||
$ml = strlen($this->bind_marker);
|
$ml = strlen($this->bind_marker);
|
||||||
|
|
||||||
// Make sure not to replace a chunk inside a string that happens to match the bind marker
|
// Make sure not to replace a chunk inside a string that happens to match the bind marker
|
||||||
if ($c = preg_match_all("/'[^']*'/i", $sql, $matches))
|
if ($c = preg_match_all("/'[^']*'|\"[^\"]*\"/i", $sql, $matches))
|
||||||
{
|
{
|
||||||
$c = preg_match_all('/'.preg_quote($this->bind_marker, '/').'/i',
|
$c = preg_match_all('/'.preg_quote($this->bind_marker, '/').'/i',
|
||||||
str_replace($matches[0],
|
str_replace($matches[0],
|
||||||
@ -922,7 +1023,12 @@ abstract class CI_DB_driver {
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
$c--;
|
$c--;
|
||||||
$sql = substr_replace($sql, $this->escape($binds[$c]), $matches[0][$c][1], $ml);
|
$escaped_value = $this->escape($binds[$c]);
|
||||||
|
if (is_array($escaped_value))
|
||||||
|
{
|
||||||
|
$escaped_value = '('.implode(',', $escaped_value).')';
|
||||||
|
}
|
||||||
|
$sql = substr_replace($sql, $escaped_value, $matches[0][$c][1], $ml);
|
||||||
}
|
}
|
||||||
while ($c !== 0);
|
while ($c !== 0);
|
||||||
|
|
||||||
@ -939,7 +1045,7 @@ abstract class CI_DB_driver {
|
|||||||
*/
|
*/
|
||||||
public function is_write_type($sql)
|
public function is_write_type($sql)
|
||||||
{
|
{
|
||||||
return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s/i', $sql);
|
return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX|MERGE)\s/i', $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -948,7 +1054,7 @@ abstract class CI_DB_driver {
|
|||||||
* Calculate the aggregate query elapsed time
|
* Calculate the aggregate query elapsed time
|
||||||
*
|
*
|
||||||
* @param int The number of decimal places
|
* @param int The number of decimal places
|
||||||
* @return int
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function elapsed_time($decimals = 6)
|
public function elapsed_time($decimals = 6)
|
||||||
{
|
{
|
||||||
@ -992,7 +1098,12 @@ abstract class CI_DB_driver {
|
|||||||
*/
|
*/
|
||||||
public function escape($str)
|
public function escape($str)
|
||||||
{
|
{
|
||||||
if (is_string($str) OR (is_object($str) && method_exists($str, '__toString')))
|
if (is_array($str))
|
||||||
|
{
|
||||||
|
$str = array_map(array(&$this, 'escape'), $str);
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
elseif (is_string($str) OR (is_object($str) && method_exists($str, '__toString')))
|
||||||
{
|
{
|
||||||
return "'".$this->escape_str($str)."'";
|
return "'".$this->escape_str($str)."'";
|
||||||
}
|
}
|
||||||
@ -1013,7 +1124,7 @@ abstract class CI_DB_driver {
|
|||||||
/**
|
/**
|
||||||
* Escape String
|
* Escape String
|
||||||
*
|
*
|
||||||
* @param string $str
|
* @param string|string[] $str Input string
|
||||||
* @param bool $like Whether or not the string will be used in a LIKE condition
|
* @param bool $like Whether or not the string will be used in a LIKE condition
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -1063,14 +1174,14 @@ abstract class CI_DB_driver {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform-dependant string escape
|
* Platform-dependent string escape
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function _escape_str($str)
|
protected function _escape_str($str)
|
||||||
{
|
{
|
||||||
return str_replace("'", "''", remove_invisible_characters($str));
|
return str_replace("'", "''", remove_invisible_characters($str, FALSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -1081,10 +1192,10 @@ abstract class CI_DB_driver {
|
|||||||
* Retrieves the primary key. It assumes that the row in the first
|
* Retrieves the primary key. It assumes that the row in the first
|
||||||
* position is the primary key
|
* position is the primary key
|
||||||
*
|
*
|
||||||
* @param string the table name
|
* @param string $table Table name
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function primary($table = '')
|
public function primary($table)
|
||||||
{
|
{
|
||||||
$fields = $this->list_fields($table);
|
$fields = $this->list_fields($table);
|
||||||
return is_array($fields) ? current($fields) : FALSE;
|
return is_array($fields) ? current($fields) : FALSE;
|
||||||
@ -1192,29 +1303,18 @@ abstract class CI_DB_driver {
|
|||||||
/**
|
/**
|
||||||
* Fetch Field Names
|
* Fetch Field Names
|
||||||
*
|
*
|
||||||
* @param string the table name
|
* @param string $table Table name
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function list_fields($table = '')
|
public function list_fields($table)
|
||||||
{
|
{
|
||||||
// Is there a cached result?
|
|
||||||
if (isset($this->data_cache['field_names'][$table]))
|
|
||||||
{
|
|
||||||
return $this->data_cache['field_names'][$table];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($table === '')
|
|
||||||
{
|
|
||||||
return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FALSE === ($sql = $this->_list_columns($table)))
|
if (FALSE === ($sql = $this->_list_columns($table)))
|
||||||
{
|
{
|
||||||
return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE;
|
return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->query($sql);
|
$query = $this->query($sql);
|
||||||
$this->data_cache['field_names'][$table] = array();
|
$fields = array();
|
||||||
|
|
||||||
foreach ($query->result_array() as $row)
|
foreach ($query->result_array() as $row)
|
||||||
{
|
{
|
||||||
@ -1236,10 +1336,10 @@ abstract class CI_DB_driver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->data_cache['field_names'][$table][] = $row[$key];
|
$fields[] = $row[$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->data_cache['field_names'][$table];
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -1261,18 +1361,13 @@ abstract class CI_DB_driver {
|
|||||||
/**
|
/**
|
||||||
* Returns an object with field data
|
* Returns an object with field data
|
||||||
*
|
*
|
||||||
* @param string the table name
|
* @param string $table the table name
|
||||||
* @return object
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function field_data($table = '')
|
public function field_data($table)
|
||||||
{
|
{
|
||||||
if ($table === '')
|
|
||||||
{
|
|
||||||
return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$query = $this->query($this->_field_data($this->protect_identifiers($table, TRUE, NULL, FALSE)));
|
$query = $this->query($this->_field_data($this->protect_identifiers($table, TRUE, NULL, FALSE)));
|
||||||
return $query->field_data();
|
return ($query) ? $query->field_data() : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -1427,7 +1522,7 @@ abstract class CI_DB_driver {
|
|||||||
return 'UPDATE '.$table.' SET '.implode(', ', $valstr)
|
return 'UPDATE '.$table.' SET '.implode(', ', $valstr)
|
||||||
.$this->_compile_wh('qb_where')
|
.$this->_compile_wh('qb_where')
|
||||||
.$this->_compile_order_by()
|
.$this->_compile_order_by()
|
||||||
.($this->qb_limit ? ' LIMIT '.$this->qb_limit : '');
|
.($this->qb_limit !== FALSE ? ' LIMIT '.$this->qb_limit : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -1461,18 +1556,18 @@ abstract class CI_DB_driver {
|
|||||||
? '\s+'.preg_quote(trim(sprintf($this->_like_escape_str, $this->_like_escape_chr)), '/')
|
? '\s+'.preg_quote(trim(sprintf($this->_like_escape_str, $this->_like_escape_chr)), '/')
|
||||||
: '';
|
: '';
|
||||||
$_operators = array(
|
$_operators = array(
|
||||||
'\s*(?:<|>|!)?=\s*', // =, <=, >=, !=
|
'\s*(?:<|>|!)?=\s*', // =, <=, >=, !=
|
||||||
'\s*<>?\s*', // <, <>
|
'\s*<>?\s*', // <, <>
|
||||||
'\s*>\s*', // >
|
'\s*>\s*', // >
|
||||||
'\s+IS NULL', // IS NULL
|
'\s+IS NULL', // IS NULL
|
||||||
'\s+IS NOT NULL', // IS NOT NULL
|
'\s+IS NOT NULL', // IS NOT NULL
|
||||||
'\s+EXISTS\s*\([^\)]+\)', // EXISTS(sql)
|
'\s+EXISTS\s*\(.*\)', // EXISTS(sql)
|
||||||
'\s+NOT EXISTS\s*\([^\)]+\)', // NOT EXISTS(sql)
|
'\s+NOT EXISTS\s*\(.*\)', // NOT EXISTS(sql)
|
||||||
'\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value
|
'\s+BETWEEN\s+', // BETWEEN value AND value
|
||||||
'\s+IN\s*\([^\)]+\)', // IN(list)
|
'\s+IN\s*\(.*\)', // IN(list)
|
||||||
'\s+NOT IN\s*\([^\)]+\)', // NOT IN (list)
|
'\s+NOT IN\s*\(.*\)', // NOT IN (list)
|
||||||
'\s+LIKE\s+\S+'.$_les, // LIKE 'expr'[ ESCAPE '%s']
|
'\s+LIKE\s+\S.*('.$_les.')?', // LIKE 'expr'[ ESCAPE '%s']
|
||||||
'\s+NOT LIKE\s+\S+'.$_les // NOT LIKE 'expr'[ ESCAPE '%s']
|
'\s+NOT LIKE\s+\S.*('.$_les.')?' // NOT LIKE 'expr'[ ESCAPE '%s']
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1618,7 +1713,7 @@ abstract class CI_DB_driver {
|
|||||||
/**
|
/**
|
||||||
* Close DB Connection
|
* Close DB Connection
|
||||||
*
|
*
|
||||||
* This method would be overriden by most of the drivers.
|
* This method would be overridden by most of the drivers.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -1693,7 +1788,7 @@ abstract class CI_DB_driver {
|
|||||||
* the table prefix onto it. Some logic is necessary in order to deal with
|
* the table prefix onto it. Some logic is necessary in order to deal with
|
||||||
* column names that include the path. Consider a query like this:
|
* column names that include the path. Consider a query like this:
|
||||||
*
|
*
|
||||||
* SELECT * FROM hostname.database.table.column AS c FROM hostname.database.table
|
* SELECT hostname.database.table.column AS c FROM hostname.database.table
|
||||||
*
|
*
|
||||||
* Or a query with aliasing:
|
* Or a query with aliasing:
|
||||||
*
|
*
|
||||||
@ -1735,13 +1830,13 @@ abstract class CI_DB_driver {
|
|||||||
//
|
//
|
||||||
// Added exception for single quotes as well, we don't want to alter
|
// Added exception for single quotes as well, we don't want to alter
|
||||||
// literal strings. -- Narf
|
// literal strings. -- Narf
|
||||||
if (strpos($item, '(') !== FALSE OR strpos($item, "'") !== FALSE)
|
if (strcspn($item, "()'") !== strlen($item))
|
||||||
{
|
{
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert tabs or multiple spaces into single spaces
|
// Convert tabs or multiple spaces into single spaces
|
||||||
$item = preg_replace('/\s+/', ' ', $item);
|
$item = preg_replace('/\s+/', ' ', trim($item));
|
||||||
|
|
||||||
// If the item has an alias declaration we remove it and set it aside.
|
// If the item has an alias declaration we remove it and set it aside.
|
||||||
// Note: strripos() is used in order to support spaces in table names
|
// Note: strripos() is used in order to support spaces in table names
|
||||||
@ -1769,12 +1864,15 @@ abstract class CI_DB_driver {
|
|||||||
// with an alias. While we're at it, we will escape the components
|
// with an alias. While we're at it, we will escape the components
|
||||||
if (strpos($item, '.') !== FALSE)
|
if (strpos($item, '.') !== FALSE)
|
||||||
{
|
{
|
||||||
$parts = explode('.', $item);
|
$parts = explode('.', $item);
|
||||||
|
|
||||||
// Does the first segment of the exploded item match
|
// Does the first segment of the exploded item match
|
||||||
// one of the aliases previously identified? If so,
|
// one of the aliases previously identified? If so,
|
||||||
// we have nothing more to do other than escape the item
|
// we have nothing more to do other than escape the item
|
||||||
if (in_array($parts[0], $this->qb_aliased_tables))
|
//
|
||||||
|
// NOTE: The ! empty() condition prevents this method
|
||||||
|
// from breaking when QB isn't enabled.
|
||||||
|
if ( ! empty($this->qb_aliased_tables) && in_array($parts[0], $this->qb_aliased_tables))
|
||||||
{
|
{
|
||||||
if ($protect_identifiers === TRUE)
|
if ($protect_identifiers === TRUE)
|
||||||
{
|
{
|
||||||
@ -1822,15 +1920,19 @@ abstract class CI_DB_driver {
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dbprefix may've already been applied, with or without the identifier escaped
|
||||||
|
$ec = '(?<ec>'.preg_quote(is_array($this->_escape_char) ? $this->_escape_char[0] : $this->_escape_char).')?';
|
||||||
|
isset($ec[0]) && $ec .= '?'; // Just in case someone has disabled escaping by forcing an empty escape character
|
||||||
|
|
||||||
// Verify table prefix and replace if necessary
|
// Verify table prefix and replace if necessary
|
||||||
if ($this->swap_pre !== '' && strpos($parts[$i], $this->swap_pre) === 0)
|
if ($this->swap_pre !== '' && preg_match('#^'.$ec.preg_quote($this->swap_pre).'#', $parts[$i]))
|
||||||
{
|
{
|
||||||
$parts[$i] = preg_replace('/^'.$this->swap_pre.'(\S+?)/', $this->dbprefix.'\\1', $parts[$i]);
|
$parts[$i] = preg_replace('#^'.$ec.preg_quote($this->swap_pre).'(\S+?)#', '\\1'.$this->dbprefix.'\\2', $parts[$i]);
|
||||||
}
|
}
|
||||||
// We only add the table prefix if it does not already exist
|
// We only add the table prefix if it does not already exist
|
||||||
elseif (strpos($parts[$i], $this->dbprefix) !== 0)
|
else
|
||||||
{
|
{
|
||||||
$parts[$i] = $this->dbprefix.$parts[$i];
|
preg_match('#^'.$ec.preg_quote($this->dbprefix).'#', $parts[$i]) OR $parts[$i] = $this->dbprefix.$parts[$i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the parts back together
|
// Put the parts back together
|
||||||
@ -1881,6 +1983,3 @@ abstract class CI_DB_driver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file DB_driver.php */
|
|
||||||
/* Location: ./system/database/DB_driver.php */
|
|
160
system/database/DB_forge.php
Executable file → Normal file
160
system/database/DB_forge.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
abstract class CI_DB_forge {
|
abstract class CI_DB_forge {
|
||||||
|
|
||||||
@ -132,7 +143,7 @@ abstract class CI_DB_forge {
|
|||||||
protected $_unsigned = TRUE;
|
protected $_unsigned = TRUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NULL value representatin in CREATE/ALTER TABLE statements
|
* NULL value representation in CREATE/ALTER TABLE statements
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
@ -156,7 +167,7 @@ abstract class CI_DB_forge {
|
|||||||
public function __construct(&$db)
|
public function __construct(&$db)
|
||||||
{
|
{
|
||||||
$this->db =& $db;
|
$this->db =& $db;
|
||||||
log_message('debug', 'Database Forge Class Initialized');
|
log_message('info', 'Database Forge Class Initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -173,7 +184,7 @@ abstract class CI_DB_forge {
|
|||||||
{
|
{
|
||||||
return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
|
return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
|
||||||
}
|
}
|
||||||
elseif ( ! $this->db->query(sprintf($this->_create_database, $db_name, $this->db->char_set, $this->db->dbcollat)))
|
elseif ( ! $this->db->query(sprintf($this->_create_database, $this->db->escape_identifiers($db_name), $this->db->char_set, $this->db->dbcollat)))
|
||||||
{
|
{
|
||||||
return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
|
return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
|
||||||
}
|
}
|
||||||
@ -196,16 +207,11 @@ abstract class CI_DB_forge {
|
|||||||
*/
|
*/
|
||||||
public function drop_database($db_name)
|
public function drop_database($db_name)
|
||||||
{
|
{
|
||||||
if ($db_name === '')
|
if ($this->_drop_database === FALSE)
|
||||||
{
|
|
||||||
show_error('A table name is required for that operation.');
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
elseif ($this->_drop_database === FALSE)
|
|
||||||
{
|
{
|
||||||
return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
|
return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
|
||||||
}
|
}
|
||||||
elseif ( ! $this->db->query(sprintf($this->_drop_database, $db_name)))
|
elseif ( ! $this->db->query(sprintf($this->_drop_database, $this->db->escape_identifiers($db_name))))
|
||||||
{
|
{
|
||||||
return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
|
return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
|
||||||
}
|
}
|
||||||
@ -231,13 +237,14 @@ abstract class CI_DB_forge {
|
|||||||
* @param bool $primary
|
* @param bool $primary
|
||||||
* @return CI_DB_forge
|
* @return CI_DB_forge
|
||||||
*/
|
*/
|
||||||
public function add_key($key = '', $primary = FALSE)
|
public function add_key($key, $primary = FALSE)
|
||||||
{
|
{
|
||||||
if (empty($key))
|
// DO NOT change this! This condition is only applicable
|
||||||
{
|
// for PRIMARY keys because you can only have one such,
|
||||||
show_error('Key information is required for that operation.');
|
// and therefore all fields you add to it will be included
|
||||||
}
|
// in the same, composite PRIMARY KEY.
|
||||||
|
//
|
||||||
|
// It's not the same for regular indexes.
|
||||||
if ($primary === TRUE && is_array($key))
|
if ($primary === TRUE && is_array($key))
|
||||||
{
|
{
|
||||||
foreach ($key as $one)
|
foreach ($key as $one)
|
||||||
@ -268,13 +275,8 @@ abstract class CI_DB_forge {
|
|||||||
* @param array $field
|
* @param array $field
|
||||||
* @return CI_DB_forge
|
* @return CI_DB_forge
|
||||||
*/
|
*/
|
||||||
public function add_field($field = '')
|
public function add_field($field)
|
||||||
{
|
{
|
||||||
if (empty($field))
|
|
||||||
{
|
|
||||||
show_error('Field information is required.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_string($field))
|
if (is_string($field))
|
||||||
{
|
{
|
||||||
if ($field === 'id')
|
if ($field === 'id')
|
||||||
@ -317,7 +319,7 @@ abstract class CI_DB_forge {
|
|||||||
* @param array $attributes Associative array of table attributes
|
* @param array $attributes Associative array of table attributes
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function create_table($table = '', $if_not_exists = FALSE, array $attributes = array())
|
public function create_table($table, $if_not_exists = FALSE, array $attributes = array())
|
||||||
{
|
{
|
||||||
if ($table === '')
|
if ($table === '')
|
||||||
{
|
{
|
||||||
@ -346,7 +348,10 @@ abstract class CI_DB_forge {
|
|||||||
|
|
||||||
if (($result = $this->db->query($sql)) !== FALSE)
|
if (($result = $this->db->query($sql)) !== FALSE)
|
||||||
{
|
{
|
||||||
empty($this->db->data_cache['table_names']) OR $this->db->data_cache['table_names'][] = $table;
|
if (isset($this->db->data_cache['table_names']))
|
||||||
|
{
|
||||||
|
$this->db->data_cache['table_names'][] = $table;
|
||||||
|
}
|
||||||
|
|
||||||
// Most databases don't support creating indexes from within the CREATE TABLE statement
|
// Most databases don't support creating indexes from within the CREATE TABLE statement
|
||||||
if ( ! empty($this->keys))
|
if ( ! empty($this->keys))
|
||||||
@ -380,10 +385,8 @@ abstract class CI_DB_forge {
|
|||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
$if_not_exists = FALSE;
|
||||||
$if_not_exists = FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = ($if_not_exists)
|
$sql = ($if_not_exists)
|
||||||
@ -457,12 +460,7 @@ abstract class CI_DB_forge {
|
|||||||
return ($this->db->db_debug) ? $this->db->display_error('db_table_name_required') : FALSE;
|
return ($this->db->db_debug) ? $this->db->display_error('db_table_name_required') : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->_drop_table($this->db->dbprefix.$table_name, $if_exists);
|
if (($query = $this->_drop_table($this->db->dbprefix.$table_name, $if_exists)) === TRUE)
|
||||||
if ($query === FALSE)
|
|
||||||
{
|
|
||||||
return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
|
|
||||||
}
|
|
||||||
elseif ($query === TRUE)
|
|
||||||
{
|
{
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -491,7 +489,7 @@ abstract class CI_DB_forge {
|
|||||||
*
|
*
|
||||||
* @param string $table Table name
|
* @param string $table Table name
|
||||||
* @param bool $if_exists Whether to add an IF EXISTS condition
|
* @param bool $if_exists Whether to add an IF EXISTS condition
|
||||||
* @return string
|
* @return mixed (Returns a platform-specific DROP table string, or TRUE to indicate there's nothing to do)
|
||||||
*/
|
*/
|
||||||
protected function _drop_table($table, $if_exists)
|
protected function _drop_table($table, $if_exists)
|
||||||
{
|
{
|
||||||
@ -564,18 +562,10 @@ abstract class CI_DB_forge {
|
|||||||
* @param string $_after Column for AFTER clause (deprecated)
|
* @param string $_after Column for AFTER clause (deprecated)
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function add_column($table = '', $field = array(), $_after = NULL)
|
public function add_column($table, $field, $_after = NULL)
|
||||||
{
|
{
|
||||||
if ($table === '')
|
|
||||||
{
|
|
||||||
show_error('A table name is required for that operation.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Work-around for literal column definitions
|
// Work-around for literal column definitions
|
||||||
if ( ! is_array($field))
|
is_array($field) OR $field = array($field);
|
||||||
{
|
|
||||||
$field = array($field);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (array_keys($field) as $k)
|
foreach (array_keys($field) as $k)
|
||||||
{
|
{
|
||||||
@ -615,18 +605,8 @@ abstract class CI_DB_forge {
|
|||||||
* @param string $column_name Column name
|
* @param string $column_name Column name
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function drop_column($table = '', $column_name = '')
|
public function drop_column($table, $column_name)
|
||||||
{
|
{
|
||||||
if ($table === '')
|
|
||||||
{
|
|
||||||
show_error('A table name is required for that operation.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($column_name === '')
|
|
||||||
{
|
|
||||||
show_error('A column name is required for that operation.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = $this->_alter_table('DROP', $this->db->dbprefix.$table, $column_name);
|
$sql = $this->_alter_table('DROP', $this->db->dbprefix.$table, $column_name);
|
||||||
if ($sql === FALSE)
|
if ($sql === FALSE)
|
||||||
{
|
{
|
||||||
@ -645,18 +625,10 @@ abstract class CI_DB_forge {
|
|||||||
* @param string $field Column definition
|
* @param string $field Column definition
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function modify_column($table = '', $field = array())
|
public function modify_column($table, $field)
|
||||||
{
|
{
|
||||||
if ($table === '')
|
|
||||||
{
|
|
||||||
show_error('A table name is required for that operation.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Work-around for literal column definitions
|
// Work-around for literal column definitions
|
||||||
if ( ! is_array($field))
|
is_array($field) OR $field = array($field);
|
||||||
{
|
|
||||||
$field = array($field);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (array_keys($field) as $k)
|
foreach (array_keys($field) as $k)
|
||||||
{
|
{
|
||||||
@ -755,7 +727,7 @@ abstract class CI_DB_forge {
|
|||||||
'type' => isset($attributes['TYPE']) ? $attributes['TYPE'] : NULL,
|
'type' => isset($attributes['TYPE']) ? $attributes['TYPE'] : NULL,
|
||||||
'length' => '',
|
'length' => '',
|
||||||
'unsigned' => '',
|
'unsigned' => '',
|
||||||
'null' => '',
|
'null' => NULL,
|
||||||
'unique' => '',
|
'unique' => '',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'auto_increment' => '',
|
'auto_increment' => '',
|
||||||
@ -797,6 +769,11 @@ abstract class CI_DB_forge {
|
|||||||
$this->_attr_auto_increment($attributes, $field);
|
$this->_attr_auto_increment($attributes, $field);
|
||||||
$this->_attr_unique($attributes, $field);
|
$this->_attr_unique($attributes, $field);
|
||||||
|
|
||||||
|
if (isset($attributes['COMMENT']))
|
||||||
|
{
|
||||||
|
$field['comment'] = $this->db->escape($attributes['COMMENT']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($attributes['TYPE']) && ! empty($attributes['CONSTRAINT']))
|
if (isset($attributes['TYPE']) && ! empty($attributes['CONSTRAINT']))
|
||||||
{
|
{
|
||||||
switch (strtoupper($attributes['TYPE']))
|
switch (strtoupper($attributes['TYPE']))
|
||||||
@ -804,10 +781,6 @@ abstract class CI_DB_forge {
|
|||||||
case 'ENUM':
|
case 'ENUM':
|
||||||
case 'SET':
|
case 'SET':
|
||||||
$attributes['CONSTRAINT'] = $this->db->escape($attributes['CONSTRAINT']);
|
$attributes['CONSTRAINT'] = $this->db->escape($attributes['CONSTRAINT']);
|
||||||
$field['length'] = is_array($attributes['CONSTRAINT'])
|
|
||||||
? "('".implode("','", $attributes['CONSTRAINT'])."')"
|
|
||||||
: '('.$attributes['CONSTRAINT'].')';
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
$field['length'] = is_array($attributes['CONSTRAINT'])
|
$field['length'] = is_array($attributes['CONSTRAINT'])
|
||||||
? '('.implode(',', $attributes['CONSTRAINT']).')'
|
? '('.implode(',', $attributes['CONSTRAINT']).')'
|
||||||
@ -853,7 +826,7 @@ abstract class CI_DB_forge {
|
|||||||
*/
|
*/
|
||||||
protected function _attr_type(&$attributes)
|
protected function _attr_type(&$attributes)
|
||||||
{
|
{
|
||||||
// Usually overriden by drivers
|
// Usually overridden by drivers
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -929,7 +902,7 @@ abstract class CI_DB_forge {
|
|||||||
$field['default'] = empty($this->_null) ? '' : $this->_default.$this->_null;
|
$field['default'] = empty($this->_null) ? '' : $this->_default.$this->_null;
|
||||||
|
|
||||||
// Override the NULL attribute if that's our default
|
// Override the NULL attribute if that's our default
|
||||||
$attributes['NULL'] = NULL;
|
$attributes['NULL'] = TRUE;
|
||||||
$field['null'] = empty($this->_null) ? '' : ' '.$this->_null;
|
$field['null'] = empty($this->_null) ? '' : ' '.$this->_null;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1007,8 +980,8 @@ abstract class CI_DB_forge {
|
|||||||
/**
|
/**
|
||||||
* Process indexes
|
* Process indexes
|
||||||
*
|
*
|
||||||
* @param string $table
|
* @param string $table Table name
|
||||||
* @return string
|
* @return string[] list of SQL statements
|
||||||
*/
|
*/
|
||||||
protected function _process_indexes($table)
|
protected function _process_indexes($table)
|
||||||
{
|
{
|
||||||
@ -1058,6 +1031,3 @@ abstract class CI_DB_forge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file DB_forge.php */
|
|
||||||
/* Location: ./system/database/DB_forge.php */
|
|
452
system/database/DB_query_builder.php
Executable file → Normal file
452
system/database/DB_query_builder.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -35,7 +46,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
abstract class CI_DB_query_builder extends CI_DB_driver {
|
abstract class CI_DB_query_builder extends CI_DB_driver {
|
||||||
@ -138,6 +149,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
*/
|
*/
|
||||||
protected $qb_set = array();
|
protected $qb_set = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QB data set for update_batch()
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $qb_set_ub = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* QB aliased tables list
|
* QB aliased tables list
|
||||||
*
|
*
|
||||||
@ -196,6 +214,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
*/
|
*/
|
||||||
protected $qb_cache_join = array();
|
protected $qb_cache_join = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QB Cache aliased tables list
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $qb_cache_aliased_tables = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* QB Cache WHERE data
|
* QB Cache WHERE data
|
||||||
*
|
*
|
||||||
@ -520,40 +545,47 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
|
|
||||||
is_bool($escape) OR $escape = $this->_protect_identifiers;
|
is_bool($escape) OR $escape = $this->_protect_identifiers;
|
||||||
|
|
||||||
// Split multiple conditions
|
if ( ! $this->_has_operator($cond))
|
||||||
if ($escape === TRUE && preg_match_all('/\sAND\s|\sOR\s/i', $cond, $m, PREG_OFFSET_CAPTURE))
|
|
||||||
{
|
|
||||||
$newcond = '';
|
|
||||||
$m[0][] = array('', strlen($cond));
|
|
||||||
|
|
||||||
for ($i = 0, $c = count($m[0]), $s = 0;
|
|
||||||
$i < $c;
|
|
||||||
$s = $m[0][$i][1] + strlen($m[0][$i][0]), $i++)
|
|
||||||
{
|
|
||||||
$temp = substr($cond, $s, ($m[0][$i][1] - $s));
|
|
||||||
|
|
||||||
$newcond .= preg_match("/([\[\]\w\.'-]+)(\s*[^\"\[`'\w]+\s*)(.+)/i", $temp, $match)
|
|
||||||
? $this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3])
|
|
||||||
: $temp;
|
|
||||||
|
|
||||||
$newcond .= $m[0][$i][0];
|
|
||||||
}
|
|
||||||
|
|
||||||
$cond = ' ON '.$newcond;
|
|
||||||
}
|
|
||||||
// Split apart the condition and protect the identifiers
|
|
||||||
elseif ($escape === TRUE && preg_match("/([\[\]\w\.'-]+)(\s*[^\"\[`'\w]+\s*)(.+)/i", $cond, $match))
|
|
||||||
{
|
|
||||||
$cond = ' ON '.$this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3]);
|
|
||||||
}
|
|
||||||
elseif ( ! $this->_has_operator($cond))
|
|
||||||
{
|
{
|
||||||
$cond = ' USING ('.($escape ? $this->escape_identifiers($cond) : $cond).')';
|
$cond = ' USING ('.($escape ? $this->escape_identifiers($cond) : $cond).')';
|
||||||
}
|
}
|
||||||
else
|
elseif ($escape === FALSE)
|
||||||
{
|
{
|
||||||
$cond = ' ON '.$cond;
|
$cond = ' ON '.$cond;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Split multiple conditions
|
||||||
|
if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE))
|
||||||
|
{
|
||||||
|
$conditions = array();
|
||||||
|
$joints = $joints[0];
|
||||||
|
array_unshift($joints, array('', 0));
|
||||||
|
|
||||||
|
for ($i = count($joints) - 1, $pos = strlen($cond); $i >= 0; $i--)
|
||||||
|
{
|
||||||
|
$joints[$i][1] += strlen($joints[$i][0]); // offset
|
||||||
|
$conditions[$i] = substr($cond, $joints[$i][1], $pos - $joints[$i][1]);
|
||||||
|
$pos = $joints[$i][1] - strlen($joints[$i][0]);
|
||||||
|
$joints[$i] = $joints[$i][0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$conditions = array($cond);
|
||||||
|
$joints = array('');
|
||||||
|
}
|
||||||
|
|
||||||
|
$cond = ' ON ';
|
||||||
|
for ($i = 0, $c = count($conditions); $i < $c; $i++)
|
||||||
|
{
|
||||||
|
$operator = $this->_get_operator($conditions[$i]);
|
||||||
|
$cond .= $joints[$i];
|
||||||
|
$cond .= preg_match("/(\(*)?([\[\]\w\.'-]+)".preg_quote($operator)."(.*)/i", $conditions[$i], $match)
|
||||||
|
? $match[1].$this->protect_identifiers($match[2]).$operator.$this->protect_identifiers($match[3])
|
||||||
|
: $conditions[$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do we want to escape the table name?
|
// Do we want to escape the table name?
|
||||||
if ($escape === TRUE)
|
if ($escape === TRUE)
|
||||||
@ -635,7 +667,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
$key = array($key => $value);
|
$key = array($key => $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the escape value was not set will will base it on the global setting
|
// If the escape value was not set will base it on the global setting
|
||||||
is_bool($escape) OR $escape = $this->_protect_identifiers;
|
is_bool($escape) OR $escape = $this->_protect_identifiers;
|
||||||
|
|
||||||
foreach ($key as $k => $v)
|
foreach ($key as $k => $v)
|
||||||
@ -648,7 +680,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
{
|
{
|
||||||
if ($escape === TRUE)
|
if ($escape === TRUE)
|
||||||
{
|
{
|
||||||
$v = ' '.$this->escape($v);
|
$v = $this->escape($v);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! $this->_has_operator($k))
|
if ( ! $this->_has_operator($k))
|
||||||
@ -661,11 +693,16 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
// value appears not to have been set, assign the test to IS NULL
|
// value appears not to have been set, assign the test to IS NULL
|
||||||
$k .= ' IS NULL';
|
$k .= ' IS NULL';
|
||||||
}
|
}
|
||||||
|
elseif (preg_match('/\s*(!?=|<>|\sIS(?:\s+NOT)?\s)\s*$/i', $k, $match, PREG_OFFSET_CAPTURE))
|
||||||
|
{
|
||||||
|
$k = substr($k, 0, $match[0][1]).($match[1][0] === '=' ? ' IS NULL' : ' IS NOT NULL');
|
||||||
|
}
|
||||||
|
|
||||||
$this->{$qb_key}[] = array('condition' => $prefix.$k.$v, 'escape' => $escape);
|
${$qb_key} = array('condition' => $prefix.$k, 'value' => $v, 'escape' => $escape);
|
||||||
|
$this->{$qb_key}[] = ${$qb_key};
|
||||||
if ($this->qb_caching === TRUE)
|
if ($this->qb_caching === TRUE)
|
||||||
{
|
{
|
||||||
$this->{$qb_cache_key}[] = array('condition' => $prefix.$k.$v, 'escape' => $escape);
|
$this->{$qb_cache_key}[] = ${$qb_key};
|
||||||
$this->qb_cache_exists[] = substr($qb_key, 3);
|
$this->qb_cache_exists[] = substr($qb_key, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -779,15 +816,26 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
|
|
||||||
$not = ($not) ? ' NOT' : '';
|
$not = ($not) ? ' NOT' : '';
|
||||||
|
|
||||||
$where_in = array();
|
if ($escape === TRUE)
|
||||||
foreach ($values as $value)
|
|
||||||
{
|
{
|
||||||
$where_in[] = $this->escape($value);
|
$where_in = array();
|
||||||
|
foreach ($values as $value)
|
||||||
|
{
|
||||||
|
$where_in[] = $this->escape($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$where_in = array_values($values);
|
||||||
}
|
}
|
||||||
|
|
||||||
$prefix = (count($this->qb_where) === 0) ? $this->_group_get_type('') : $this->_group_get_type($type);
|
$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0)
|
||||||
|
? $this->_group_get_type('')
|
||||||
|
: $this->_group_get_type($type);
|
||||||
|
|
||||||
$where_in = array(
|
$where_in = array(
|
||||||
'condition' => $prefix.$key.$not.' IN('.implode(', ', $where_in).')',
|
'condition' => $prefix.$key.$not.' IN('.implode(', ', $where_in).')',
|
||||||
|
'value' => NULL,
|
||||||
'escape' => $escape
|
'escape' => $escape
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -903,41 +951,47 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is_bool($escape) OR $escape = $this->_protect_identifiers;
|
is_bool($escape) OR $escape = $this->_protect_identifiers;
|
||||||
|
// lowercase $side in case somebody writes e.g. 'BEFORE' instead of 'before' (doh)
|
||||||
|
$side = strtolower($side);
|
||||||
|
|
||||||
foreach ($field as $k => $v)
|
foreach ($field as $k => $v)
|
||||||
{
|
{
|
||||||
$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0)
|
$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0)
|
||||||
? $this->_group_get_type('') : $this->_group_get_type($type);
|
? $this->_group_get_type('') : $this->_group_get_type($type);
|
||||||
|
|
||||||
$v = $this->escape_like_str($v);
|
if ($escape === TRUE)
|
||||||
|
{
|
||||||
|
$v = $this->escape_like_str($v);
|
||||||
|
}
|
||||||
|
|
||||||
if ($side === 'none')
|
switch ($side)
|
||||||
{
|
{
|
||||||
$like_statement = "{$prefix} {$k} {$not} LIKE '{$v}'";
|
case 'none':
|
||||||
}
|
$v = "'{$v}'";
|
||||||
elseif ($side === 'before')
|
break;
|
||||||
{
|
case 'before':
|
||||||
$like_statement = "{$prefix} {$k} {$not} LIKE '%{$v}'";
|
$v = "'%{$v}'";
|
||||||
}
|
break;
|
||||||
elseif ($side === 'after')
|
case 'after':
|
||||||
{
|
$v = "'{$v}%'";
|
||||||
$like_statement = "{$prefix} {$k} {$not} LIKE '{$v}%'";
|
break;
|
||||||
}
|
case 'both':
|
||||||
else
|
default:
|
||||||
{
|
$v = "'%{$v}%'";
|
||||||
$like_statement = "{$prefix} {$k} {$not} LIKE '%{$v}%'";
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// some platforms require an escape sequence definition for LIKE wildcards
|
// some platforms require an escape sequence definition for LIKE wildcards
|
||||||
if ($this->_like_escape_str !== '')
|
if ($escape === TRUE && $this->_like_escape_str !== '')
|
||||||
{
|
{
|
||||||
$like_statement .= sprintf($this->_like_escape_str, $this->_like_escape_chr);
|
$v .= sprintf($this->_like_escape_str, $this->_like_escape_chr);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->qb_where[] = array('condition' => $like_statement, 'escape' => $escape);
|
$qb_where = array('condition' => "{$prefix} {$k} {$not} LIKE {$v}", 'value' => NULL, 'escape' => $escape);
|
||||||
|
$this->qb_where[] = $qb_where;
|
||||||
if ($this->qb_caching === TRUE)
|
if ($this->qb_caching === TRUE)
|
||||||
{
|
{
|
||||||
$this->qb_cache_where[] = array('condition' => $like_statement, 'escape' => $escape);
|
$this->qb_cache_where[] = $qb_where;
|
||||||
$this->qb_cache_exists[] = 'where';
|
$this->qb_cache_exists[] = 'where';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -962,6 +1016,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
|
$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
|
||||||
$where = array(
|
$where = array(
|
||||||
'condition' => $prefix.$not.str_repeat(' ', ++$this->qb_where_group_count).' (',
|
'condition' => $prefix.$not.str_repeat(' ', ++$this->qb_where_group_count).' (',
|
||||||
|
'value' => NULL,
|
||||||
'escape' => FALSE
|
'escape' => FALSE
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1022,6 +1077,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
$this->qb_where_group_started = FALSE;
|
$this->qb_where_group_started = FALSE;
|
||||||
$where = array(
|
$where = array(
|
||||||
'condition' => str_repeat(' ', $this->qb_where_group_count--).')',
|
'condition' => str_repeat(' ', $this->qb_where_group_count--).')',
|
||||||
|
'value' => NULL,
|
||||||
'escape' => FALSE
|
'escape' => FALSE
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1108,7 +1164,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* @param string $key
|
* @param string $key
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param bool $escape
|
* @param bool $escape
|
||||||
* @return object
|
* @return CI_DB_query_builder
|
||||||
*/
|
*/
|
||||||
public function having($key, $value = NULL, $escape = NULL)
|
public function having($key, $value = NULL, $escape = NULL)
|
||||||
{
|
{
|
||||||
@ -1125,7 +1181,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* @param string $key
|
* @param string $key
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param bool $escape
|
* @param bool $escape
|
||||||
* @return object
|
* @return CI_DB_query_builder
|
||||||
*/
|
*/
|
||||||
public function or_having($key, $value = NULL, $escape = NULL)
|
public function or_having($key, $value = NULL, $escape = NULL)
|
||||||
{
|
{
|
||||||
@ -1200,7 +1256,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* @param int $offset OFFSET value
|
* @param int $offset OFFSET value
|
||||||
* @return CI_DB_query_builder
|
* @return CI_DB_query_builder
|
||||||
*/
|
*/
|
||||||
public function limit($value, $offset = FALSE)
|
public function limit($value, $offset = 0)
|
||||||
{
|
{
|
||||||
is_null($value) OR $this->qb_limit = (int) $value;
|
is_null($value) OR $this->qb_limit = (int) $value;
|
||||||
empty($offset) OR $this->qb_offset = (int) $offset;
|
empty($offset) OR $this->qb_offset = (int) $offset;
|
||||||
@ -1234,7 +1290,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
*/
|
*/
|
||||||
protected function _limit($sql)
|
protected function _limit($sql)
|
||||||
{
|
{
|
||||||
return $sql.' LIMIT '.($this->qb_offset ? $this->qb_offset.', ' : '').$this->qb_limit;
|
return $sql.' LIMIT '.($this->qb_offset ? $this->qb_offset.', ' : '').(int) $this->qb_limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -1277,7 +1333,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* Compiles a SELECT query string and returns the sql.
|
* Compiles a SELECT query string and returns the sql.
|
||||||
*
|
*
|
||||||
* @param string the table name to select from (optional)
|
* @param string the table name to select from (optional)
|
||||||
* @param bool TRUE: resets QB values; FALSE: leave QB vaules alone
|
* @param bool TRUE: resets QB values; FALSE: leave QB values alone
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function get_compiled_select($table = '', $reset = TRUE)
|
public function get_compiled_select($table = '', $reset = TRUE)
|
||||||
@ -1309,7 +1365,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* @param string the table
|
* @param string the table
|
||||||
* @param string the limit clause
|
* @param string the limit clause
|
||||||
* @param string the offset clause
|
* @param string the offset clause
|
||||||
* @return object
|
* @return CI_DB_result
|
||||||
*/
|
*/
|
||||||
public function get($table = '', $limit = NULL, $offset = NULL)
|
public function get($table = '', $limit = NULL, $offset = NULL)
|
||||||
{
|
{
|
||||||
@ -1338,9 +1394,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* returned by an Query Builder query.
|
* returned by an Query Builder query.
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
|
* @param bool the reset clause
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function count_all_results($table = '')
|
public function count_all_results($table = '', $reset = TRUE)
|
||||||
{
|
{
|
||||||
if ($table !== '')
|
if ($table !== '')
|
||||||
{
|
{
|
||||||
@ -1348,10 +1405,26 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
$this->from($table);
|
$this->from($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = ($this->qb_distinct === TRUE)
|
// ORDER BY usage is often problematic here (most notably
|
||||||
|
// on Microsoft SQL Server) and ultimately unnecessary
|
||||||
|
// for selecting COUNT(*) ...
|
||||||
|
$qb_orderby = $this->qb_orderby;
|
||||||
|
$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)
|
||||||
? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")
|
? $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')));
|
: $this->query($this->_compile_select($this->_count_string.$this->protect_identifiers('numrows')));
|
||||||
$this->_reset_select();
|
|
||||||
|
if ($reset === TRUE)
|
||||||
|
{
|
||||||
|
$this->_reset_select();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->qb_orderby = $qb_orderby;
|
||||||
|
$this->qb_cache_orderby = $qb_cache_orderby;
|
||||||
|
}
|
||||||
|
|
||||||
if ($result->num_rows() === 0)
|
if ($result->num_rows() === 0)
|
||||||
{
|
{
|
||||||
@ -1365,7 +1438,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get_Where
|
* get_where()
|
||||||
*
|
*
|
||||||
* Allows the where clause, limit and offset to be added directly
|
* Allows the where clause, limit and offset to be added directly
|
||||||
*
|
*
|
||||||
@ -1373,7 +1446,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* @param string $where
|
* @param string $where
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
* @param int $offset
|
* @param int $offset
|
||||||
* @return object
|
* @return CI_DB_result
|
||||||
*/
|
*/
|
||||||
public function get_where($table = '', $where = NULL, $limit = NULL, $offset = NULL)
|
public function get_where($table = '', $where = NULL, $limit = NULL, $offset = NULL)
|
||||||
{
|
{
|
||||||
@ -1409,20 +1482,26 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* @param bool $escape Whether to escape values and identifiers
|
* @param bool $escape Whether to escape values and identifiers
|
||||||
* @return int Number of rows inserted or FALSE on failure
|
* @return int Number of rows inserted or FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function insert_batch($table = '', $set = NULL, $escape = NULL)
|
public function insert_batch($table, $set = NULL, $escape = NULL, $batch_size = 100)
|
||||||
{
|
{
|
||||||
if ($set !== NULL)
|
if ($set === NULL)
|
||||||
{
|
{
|
||||||
|
if (empty($this->qb_set))
|
||||||
|
{
|
||||||
|
return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (empty($set))
|
||||||
|
{
|
||||||
|
return ($this->db_debug) ? $this->display_error('insert_batch() called with no data') : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
$this->set_insert_batch($set, '', $escape);
|
$this->set_insert_batch($set, '', $escape);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($this->qb_set) === 0)
|
if (strlen($table) === 0)
|
||||||
{
|
|
||||||
// No valid data array. Folds in cases where keys and values did not match up
|
|
||||||
return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($table === '')
|
|
||||||
{
|
{
|
||||||
if ( ! isset($this->qb_from[0]))
|
if ( ! isset($this->qb_from[0]))
|
||||||
{
|
{
|
||||||
@ -1434,10 +1513,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
|
|
||||||
// Batch this baby
|
// Batch this baby
|
||||||
$affected_rows = 0;
|
$affected_rows = 0;
|
||||||
for ($i = 0, $total = count($this->qb_set); $i < $total; $i += 100)
|
for ($i = 0, $total = count($this->qb_set); $i < $total; $i += $batch_size)
|
||||||
{
|
{
|
||||||
$this->query($this->_insert_batch($this->protect_identifiers($table, TRUE, $escape, FALSE), $this->qb_keys, array_slice($this->qb_set, $i, 100)));
|
if ($this->query($this->_insert_batch($this->protect_identifiers($table, TRUE, $escape, FALSE), $this->qb_keys, array_slice($this->qb_set, $i, $batch_size))))
|
||||||
$affected_rows += $this->affected_rows();
|
{
|
||||||
|
$affected_rows += $this->affected_rows();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_reset_write();
|
$this->_reset_write();
|
||||||
@ -1482,7 +1563,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
|
|
||||||
is_bool($escape) OR $escape = $this->_protect_identifiers;
|
is_bool($escape) OR $escape = $this->_protect_identifiers;
|
||||||
|
|
||||||
$keys = array_keys($this->_object_to_array(current($key)));
|
$keys = array_keys($this->_object_to_array(reset($key)));
|
||||||
sort($keys);
|
sort($keys);
|
||||||
|
|
||||||
foreach ($key as $row)
|
foreach ($key as $row)
|
||||||
@ -1563,7 +1644,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* @param string the table to insert data into
|
* @param string the table to insert data into
|
||||||
* @param array an associative array of insert values
|
* @param array an associative array of insert values
|
||||||
* @param bool $escape Whether to escape values and identifiers
|
* @param bool $escape Whether to escape values and identifiers
|
||||||
* @return object
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function insert($table = '', $set = NULL, $escape = NULL)
|
public function insert($table = '', $set = NULL, $escape = NULL)
|
||||||
{
|
{
|
||||||
@ -1629,7 +1710,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
*
|
*
|
||||||
* @param string the table to replace data into
|
* @param string the table to replace data into
|
||||||
* @param array an associative array of insert values
|
* @param array an associative array of insert values
|
||||||
* @return object
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function replace($table = '', $set = NULL)
|
public function replace($table = '', $set = NULL)
|
||||||
{
|
{
|
||||||
@ -1684,7 +1765,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* Groups tables in FROM clauses if needed, so there is no confusion
|
* Groups tables in FROM clauses if needed, so there is no confusion
|
||||||
* about operator precedence.
|
* about operator precedence.
|
||||||
*
|
*
|
||||||
* Note: This is only used (and overriden) by MySQL and CUBRID.
|
* Note: This is only used (and overridden) by MySQL and CUBRID.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -1714,7 +1795,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set);
|
$sql = $this->_update($this->qb_from[0], $this->qb_set);
|
||||||
|
|
||||||
if ($reset === TRUE)
|
if ($reset === TRUE)
|
||||||
{
|
{
|
||||||
@ -1735,7 +1816,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* @param array $set An associative array of update values
|
* @param array $set An associative array of update values
|
||||||
* @param mixed $where
|
* @param mixed $where
|
||||||
* @param int $limit
|
* @param int $limit
|
||||||
* @return object
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function update($table = '', $set = NULL, $where = NULL, $limit = NULL)
|
public function update($table = '', $set = NULL, $where = NULL, $limit = NULL)
|
||||||
{
|
{
|
||||||
@ -1762,7 +1843,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
$this->limit($limit);
|
$this->limit($limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set);
|
$sql = $this->_update($this->qb_from[0], $this->qb_set);
|
||||||
$this->_reset_write();
|
$this->_reset_write();
|
||||||
return $this->query($sql);
|
return $this->query($sql);
|
||||||
}
|
}
|
||||||
@ -1779,7 +1860,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* @param string the table to update data on
|
* @param string the table to update data on
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function _validate_update($table = '')
|
protected function _validate_update($table)
|
||||||
{
|
{
|
||||||
if (count($this->qb_set) === 0)
|
if (count($this->qb_set) === 0)
|
||||||
{
|
{
|
||||||
@ -1788,7 +1869,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
|
|
||||||
if ($table !== '')
|
if ($table !== '')
|
||||||
{
|
{
|
||||||
$this->qb_from[0] = $table;
|
$this->qb_from = array($this->protect_identifiers($table, TRUE, NULL, FALSE));
|
||||||
}
|
}
|
||||||
elseif ( ! isset($this->qb_from[0]))
|
elseif ( ! isset($this->qb_from[0]))
|
||||||
{
|
{
|
||||||
@ -1810,7 +1891,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* @param string the where key
|
* @param string the where key
|
||||||
* @return int number of rows affected or FALSE on failure
|
* @return int number of rows affected or FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function update_batch($table = '', $set = NULL, $index = NULL)
|
public function update_batch($table, $set = NULL, $index = NULL, $batch_size = 100)
|
||||||
{
|
{
|
||||||
// Combine any cached components with the current statements
|
// Combine any cached components with the current statements
|
||||||
$this->_merge_cache();
|
$this->_merge_cache();
|
||||||
@ -1820,17 +1901,24 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
return ($this->db_debug) ? $this->display_error('db_must_use_index') : FALSE;
|
return ($this->db_debug) ? $this->display_error('db_must_use_index') : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($set !== NULL)
|
if ($set === NULL)
|
||||||
{
|
{
|
||||||
|
if (empty($this->qb_set_ub))
|
||||||
|
{
|
||||||
|
return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (empty($set))
|
||||||
|
{
|
||||||
|
return ($this->db_debug) ? $this->display_error('update_batch() called with no data') : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
$this->set_update_batch($set, $index);
|
$this->set_update_batch($set, $index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($this->qb_set) === 0)
|
if (strlen($table) === 0)
|
||||||
{
|
|
||||||
return ($this->db_debug) ? $this->display_error('db_must_use_set') : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($table === '')
|
|
||||||
{
|
{
|
||||||
if ( ! isset($this->qb_from[0]))
|
if ( ! isset($this->qb_from[0]))
|
||||||
{
|
{
|
||||||
@ -1842,10 +1930,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
|
|
||||||
// Batch this baby
|
// Batch this baby
|
||||||
$affected_rows = 0;
|
$affected_rows = 0;
|
||||||
for ($i = 0, $total = count($this->qb_set); $i < $total; $i += 100)
|
for ($i = 0, $total = count($this->qb_set_ub); $i < $total; $i += $batch_size)
|
||||||
{
|
{
|
||||||
$this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set, $i, 100), $this->protect_identifiers($index)));
|
if ($this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->qb_set_ub, $i, $batch_size), $index)))
|
||||||
$affected_rows += $this->affected_rows();
|
{
|
||||||
|
$affected_rows += $this->affected_rows();
|
||||||
|
}
|
||||||
|
|
||||||
$this->qb_where = array();
|
$this->qb_where = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1870,13 +1961,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
$ids = array();
|
$ids = array();
|
||||||
foreach ($values as $key => $val)
|
foreach ($values as $key => $val)
|
||||||
{
|
{
|
||||||
$ids[] = $val[$index];
|
$ids[] = $val[$index]['value'];
|
||||||
|
|
||||||
foreach (array_keys($val) as $field)
|
foreach (array_keys($val) as $field)
|
||||||
{
|
{
|
||||||
if ($field !== $index)
|
if ($field !== $index)
|
||||||
{
|
{
|
||||||
$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
|
$final[$val[$field]['field']][] = 'WHEN '.$val[$index]['field'].' = '.$val[$index]['value'].' THEN '.$val[$field]['value'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1889,7 +1980,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
.'ELSE '.$k.' END, ';
|
.'ELSE '.$k.' END, ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE);
|
$this->where($val[$index]['field'].' IN('.implode(',', $ids).')', NULL, FALSE);
|
||||||
|
|
||||||
return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where');
|
return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where');
|
||||||
}
|
}
|
||||||
@ -1926,7 +2017,10 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
$index_set = TRUE;
|
$index_set = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$clean[$this->protect_identifiers($k2, FALSE, $escape)] = ($escape === FALSE) ? $v2 : $this->escape($v2);
|
$clean[$k2] = array(
|
||||||
|
'field' => $this->protect_identifiers($k2, FALSE, $escape),
|
||||||
|
'value' => ($escape === FALSE ? $v2 : $this->escape($v2))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($index_set === FALSE)
|
if ($index_set === FALSE)
|
||||||
@ -1934,7 +2028,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
return $this->display_error('db_batch_missing_index');
|
return $this->display_error('db_batch_missing_index');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->qb_set[] = $clean;
|
$this->qb_set_ub[] = $clean;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -1948,7 +2042,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* Compiles a delete string and runs "DELETE FROM table"
|
* Compiles a delete string and runs "DELETE FROM table"
|
||||||
*
|
*
|
||||||
* @param string the table to empty
|
* @param string the table to empty
|
||||||
* @return object
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function empty_table($table = '')
|
public function empty_table($table = '')
|
||||||
{
|
{
|
||||||
@ -1981,7 +2075,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
* This function maps to "DELETE FROM table"
|
* This function maps to "DELETE FROM table"
|
||||||
*
|
*
|
||||||
* @param string the table to truncate
|
* @param string the table to truncate
|
||||||
* @return object
|
* @return bool TRUE on success, FALSE on failure
|
||||||
*/
|
*/
|
||||||
public function truncate($table = '')
|
public function truncate($table = '')
|
||||||
{
|
{
|
||||||
@ -2070,10 +2164,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
}
|
}
|
||||||
elseif (is_array($table))
|
elseif (is_array($table))
|
||||||
{
|
{
|
||||||
|
empty($where) && $reset_data = FALSE;
|
||||||
|
|
||||||
foreach ($table as $single_table)
|
foreach ($table as $single_table)
|
||||||
{
|
{
|
||||||
$this->delete($single_table, $where, $limit, $reset_data);
|
$this->delete($single_table, $where, $limit, $reset_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2118,7 +2215,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
protected function _delete($table)
|
protected function _delete($table)
|
||||||
{
|
{
|
||||||
return 'DELETE FROM '.$table.$this->_compile_wh('qb_where')
|
return 'DELETE FROM '.$table.$this->_compile_wh('qb_where')
|
||||||
.($this->qb_limit ? ' LIMIT '.$this->qb_limit : '');
|
.($this->qb_limit !== FALSE ? ' LIMIT '.$this->qb_limit : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -2194,9 +2291,14 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
$table = trim(strrchr($table, ' '));
|
$table = trim(strrchr($table, ' '));
|
||||||
|
|
||||||
// Store the alias, if it doesn't already exist
|
// Store the alias, if it doesn't already exist
|
||||||
if ( ! in_array($table, $this->qb_aliased_tables))
|
if ( ! in_array($table, $this->qb_aliased_tables, TRUE))
|
||||||
{
|
{
|
||||||
$this->qb_aliased_tables[] = $table;
|
$this->qb_aliased_tables[] = $table;
|
||||||
|
if ($this->qb_caching === TRUE && ! in_array($table, $this->qb_cache_aliased_tables, TRUE))
|
||||||
|
{
|
||||||
|
$this->qb_cache_aliased_tables[] = $table;
|
||||||
|
$this->qb_cache_exists[] = 'aliased_tables';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2233,7 +2335,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Cycle through the "select" portion of the query and prep each column name.
|
// Cycle through the "select" portion of the query and prep each column name.
|
||||||
// The reason we protect identifiers here rather then in the select() function
|
// The reason we protect identifiers here rather than in the select() function
|
||||||
// is because until the user calls the from() function we don't know if there are aliases
|
// is because until the user calls the from() function we don't know if there are aliases
|
||||||
foreach ($this->qb_select as $key => $val)
|
foreach ($this->qb_select as $key => $val)
|
||||||
{
|
{
|
||||||
@ -2263,7 +2365,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
.$this->_compile_order_by(); // ORDER BY
|
.$this->_compile_order_by(); // ORDER BY
|
||||||
|
|
||||||
// LIMIT
|
// LIMIT
|
||||||
if ($this->qb_limit)
|
if ($this->qb_limit !== FALSE OR $this->qb_offset)
|
||||||
{
|
{
|
||||||
return $this->_limit($sql."\n");
|
return $this->_limit($sql."\n");
|
||||||
}
|
}
|
||||||
@ -2278,7 +2380,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
*
|
*
|
||||||
* Escapes identifiers in WHERE and HAVING statements at execution time.
|
* Escapes identifiers in WHERE and HAVING statements at execution time.
|
||||||
*
|
*
|
||||||
* Required so that aliases are tracked properly, regardless of wether
|
* Required so that aliases are tracked properly, regardless of whether
|
||||||
* where(), or_where(), having(), or_having are called prior to from(),
|
* where(), or_where(), having(), or_having are called prior to from(),
|
||||||
* join() and dbprefix is added only if needed.
|
* join() and dbprefix is added only if needed.
|
||||||
*
|
*
|
||||||
@ -2298,13 +2400,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
}
|
}
|
||||||
elseif ($this->{$qb_key}[$i]['escape'] === FALSE)
|
elseif ($this->{$qb_key}[$i]['escape'] === FALSE)
|
||||||
{
|
{
|
||||||
$this->{$qb_key}[$i] = $this->{$qb_key}[$i]['condition'];
|
$this->{$qb_key}[$i] = $this->{$qb_key}[$i]['condition'].(isset($this->{$qb_key}[$i]['value']) ? ' '.$this->{$qb_key}[$i]['value'] : '');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split multiple conditions
|
// Split multiple conditions
|
||||||
$conditions = preg_split(
|
$conditions = preg_split(
|
||||||
'/(\s*AND\s+|\s*OR\s+)/i',
|
'/((?:^|\s+)AND\s+|(?:^|\s+)OR\s+)/i',
|
||||||
$this->{$qb_key}[$i]['condition'],
|
$this->{$qb_key}[$i]['condition'],
|
||||||
-1,
|
-1,
|
||||||
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
|
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
|
||||||
@ -2337,7 +2439,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
.' '.trim($matches[3]).$matches[4].$matches[5];
|
.' '.trim($matches[3]).$matches[4].$matches[5];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->{$qb_key}[$i] = implode('', $conditions);
|
$this->{$qb_key}[$i] = implode('', $conditions).(isset($this->{$qb_key}[$i]['value']) ? ' '.$this->{$qb_key}[$i]['value'] : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($qb_key === 'qb_having' ? "\nHAVING " : "\nWHERE ")
|
return ($qb_key === 'qb_having' ? "\nHAVING " : "\nWHERE ")
|
||||||
@ -2354,7 +2456,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
*
|
*
|
||||||
* Escapes identifiers in GROUP BY statements at execution time.
|
* Escapes identifiers in GROUP BY statements at execution time.
|
||||||
*
|
*
|
||||||
* Required so that aliases are tracked properly, regardless of wether
|
* Required so that aliases are tracked properly, regardless of whether
|
||||||
* group_by() is called prior to from(), join() and dbprefix is added
|
* group_by() is called prior to from(), join() and dbprefix is added
|
||||||
* only if needed.
|
* only if needed.
|
||||||
*
|
*
|
||||||
@ -2390,7 +2492,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
*
|
*
|
||||||
* Escapes identifiers in ORDER BY statements at execution time.
|
* Escapes identifiers in ORDER BY statements at execution time.
|
||||||
*
|
*
|
||||||
* Required so that aliases are tracked properly, regardless of wether
|
* Required so that aliases are tracked properly, regardless of whether
|
||||||
* order_by() is called prior to from(), join() and dbprefix is added
|
* order_by() is called prior to from(), join() and dbprefix is added
|
||||||
* only if needed.
|
* only if needed.
|
||||||
*
|
*
|
||||||
@ -2398,26 +2500,27 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
*/
|
*/
|
||||||
protected function _compile_order_by()
|
protected function _compile_order_by()
|
||||||
{
|
{
|
||||||
if (is_array($this->qb_orderby) && count($this->qb_orderby) > 0)
|
if (empty($this->qb_orderby))
|
||||||
{
|
{
|
||||||
for ($i = 0, $c = count($this->qb_orderby); $i < $c; $i++)
|
return '';
|
||||||
{
|
}
|
||||||
if ($this->qb_orderby[$i]['escape'] !== FALSE && ! $this->_is_literal($this->qb_orderby[$i]['field']))
|
|
||||||
{
|
|
||||||
$this->qb_orderby[$i]['field'] = $this->protect_identifiers($this->qb_orderby[$i]['field']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->qb_orderby[$i] = $this->qb_orderby[$i]['field'].$this->qb_orderby[$i]['direction'];
|
for ($i = 0, $c = count($this->qb_orderby); $i < $c; $i++)
|
||||||
|
{
|
||||||
|
if (is_string($this->qb_orderby[$i]))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->qb_orderby = "\nORDER BY ".implode(', ', $this->qb_orderby);
|
if ($this->qb_orderby[$i]['escape'] !== FALSE && ! $this->_is_literal($this->qb_orderby[$i]['field']))
|
||||||
}
|
{
|
||||||
elseif (is_string($this->qb_orderby))
|
$this->qb_orderby[$i]['field'] = $this->protect_identifiers($this->qb_orderby[$i]['field']);
|
||||||
{
|
}
|
||||||
return $this->qb_orderby;
|
|
||||||
|
$this->qb_orderby[$i] = $this->qb_orderby[$i]['field'].$this->qb_orderby[$i]['direction'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return "\nORDER BY ".implode(', ', $this->qb_orderby);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -2494,11 +2597,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
*
|
*
|
||||||
* Starts QB caching
|
* Starts QB caching
|
||||||
*
|
*
|
||||||
* @return void
|
* @return CI_DB_query_builder
|
||||||
*/
|
*/
|
||||||
public function start_cache()
|
public function start_cache()
|
||||||
{
|
{
|
||||||
$this->qb_caching = TRUE;
|
$this->qb_caching = TRUE;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -2508,11 +2612,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
*
|
*
|
||||||
* Stops QB caching
|
* Stops QB caching
|
||||||
*
|
*
|
||||||
* @return void
|
* @return CI_DB_query_builder
|
||||||
*/
|
*/
|
||||||
public function stop_cache()
|
public function stop_cache()
|
||||||
{
|
{
|
||||||
$this->qb_caching = FALSE;
|
$this->qb_caching = FALSE;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -2522,7 +2627,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
*
|
*
|
||||||
* Empties the QB cache
|
* Empties the QB cache
|
||||||
*
|
*
|
||||||
* @return void
|
* @return CI_DB_query_builder
|
||||||
*/
|
*/
|
||||||
public function flush_cache()
|
public function flush_cache()
|
||||||
{
|
{
|
||||||
@ -2536,8 +2641,11 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
'qb_cache_orderby' => array(),
|
'qb_cache_orderby' => array(),
|
||||||
'qb_cache_set' => array(),
|
'qb_cache_set' => array(),
|
||||||
'qb_cache_exists' => array(),
|
'qb_cache_exists' => array(),
|
||||||
'qb_cache_no_escape' => array()
|
'qb_cache_no_escape' => array(),
|
||||||
|
'qb_cache_aliased_tables' => array()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -2585,13 +2693,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
$this->qb_no_escape = $qb_no_escape;
|
$this->qb_no_escape = $qb_no_escape;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we are "protecting identifiers" we need to examine the "from"
|
|
||||||
// portion of the query to determine if there are any aliases
|
|
||||||
if ($this->_protect_identifiers === TRUE && count($this->qb_cache_from) > 0)
|
|
||||||
{
|
|
||||||
$this->_track_aliases($this->qb_from);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -2631,12 +2732,13 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
*
|
*
|
||||||
* Publicly-visible method to reset the QB values.
|
* Publicly-visible method to reset the QB values.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return CI_DB_query_builder
|
||||||
*/
|
*/
|
||||||
public function reset_query()
|
public function reset_query()
|
||||||
{
|
{
|
||||||
$this->_reset_select();
|
$this->_reset_select();
|
||||||
$this->_reset_write();
|
$this->_reset_write();
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -2665,20 +2767,19 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
protected function _reset_select()
|
protected function _reset_select()
|
||||||
{
|
{
|
||||||
$this->_reset_run(array(
|
$this->_reset_run(array(
|
||||||
'qb_select' => array(),
|
'qb_select' => array(),
|
||||||
'qb_from' => array(),
|
'qb_from' => array(),
|
||||||
'qb_join' => array(),
|
'qb_join' => array(),
|
||||||
'qb_where' => array(),
|
'qb_where' => array(),
|
||||||
'qb_groupby' => array(),
|
'qb_groupby' => array(),
|
||||||
'qb_having' => array(),
|
'qb_having' => array(),
|
||||||
'qb_orderby' => array(),
|
'qb_orderby' => array(),
|
||||||
'qb_aliased_tables' => array(),
|
'qb_aliased_tables' => array(),
|
||||||
'qb_no_escape' => array(),
|
'qb_no_escape' => array(),
|
||||||
'qb_distinct' => FALSE,
|
'qb_distinct' => FALSE,
|
||||||
'qb_limit' => FALSE,
|
'qb_limit' => FALSE,
|
||||||
'qb_offset' => FALSE
|
'qb_offset' => FALSE
|
||||||
)
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -2694,17 +2795,14 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
|
|||||||
{
|
{
|
||||||
$this->_reset_run(array(
|
$this->_reset_run(array(
|
||||||
'qb_set' => array(),
|
'qb_set' => array(),
|
||||||
|
'qb_set_ub' => array(),
|
||||||
'qb_from' => array(),
|
'qb_from' => array(),
|
||||||
'qb_join' => array(),
|
'qb_join' => array(),
|
||||||
'qb_where' => array(),
|
'qb_where' => array(),
|
||||||
'qb_orderby' => array(),
|
'qb_orderby' => array(),
|
||||||
'qb_keys' => array(),
|
'qb_keys' => array(),
|
||||||
'qb_limit' => FALSE
|
'qb_limit' => FALSE
|
||||||
)
|
));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file DB_query_builder.php */
|
|
||||||
/* Location: ./system/database/DB_query_builder.php */
|
|
73
system/database/DB_result.php
Executable file → Normal file
73
system/database/DB_result.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -35,7 +46,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_result {
|
class CI_DB_result {
|
||||||
|
|
||||||
@ -152,10 +163,8 @@ class CI_DB_result {
|
|||||||
{
|
{
|
||||||
return $this->result_object();
|
return $this->result_object();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return $this->custom_result_object($type);
|
||||||
return $this->custom_result_object($type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -325,7 +334,8 @@ class CI_DB_result {
|
|||||||
|
|
||||||
if ($type === 'object') return $this->row_object($n);
|
if ($type === 'object') return $this->row_object($n);
|
||||||
elseif ($type === 'array') return $this->row_array($n);
|
elseif ($type === 'array') return $this->row_array($n);
|
||||||
else return $this->custom_row_object($n, $type);
|
|
||||||
|
return $this->custom_row_object($n, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -545,7 +555,7 @@ class CI_DB_result {
|
|||||||
/**
|
/**
|
||||||
* Number of fields in the result set
|
* Number of fields in the result set
|
||||||
*
|
*
|
||||||
* Overriden by driver result classes.
|
* Overridden by driver result classes.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@ -561,7 +571,7 @@ class CI_DB_result {
|
|||||||
*
|
*
|
||||||
* Generates an array of column names.
|
* Generates an array of column names.
|
||||||
*
|
*
|
||||||
* Overriden by driver result classes.
|
* Overridden by driver result classes.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -577,7 +587,7 @@ class CI_DB_result {
|
|||||||
*
|
*
|
||||||
* Generates an array of objects containing field meta-data.
|
* Generates an array of objects containing field meta-data.
|
||||||
*
|
*
|
||||||
* Overriden by driver result classes.
|
* Overridden by driver result classes.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -591,7 +601,7 @@ class CI_DB_result {
|
|||||||
/**
|
/**
|
||||||
* Free the result
|
* Free the result
|
||||||
*
|
*
|
||||||
* Overriden by driver result classes.
|
* Overridden by driver result classes.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
@ -609,7 +619,7 @@ class CI_DB_result {
|
|||||||
* this internally before fetching results to make sure the
|
* this internally before fetching results to make sure the
|
||||||
* result set starts at zero.
|
* result set starts at zero.
|
||||||
*
|
*
|
||||||
* Overriden by driver result classes.
|
* Overridden by driver result classes.
|
||||||
*
|
*
|
||||||
* @param int $n
|
* @param int $n
|
||||||
* @return bool
|
* @return bool
|
||||||
@ -626,7 +636,7 @@ class CI_DB_result {
|
|||||||
*
|
*
|
||||||
* Returns the result set as an array.
|
* Returns the result set as an array.
|
||||||
*
|
*
|
||||||
* Overriden by driver result classes.
|
* Overridden by driver result classes.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -642,17 +652,14 @@ class CI_DB_result {
|
|||||||
*
|
*
|
||||||
* Returns the result set as an object.
|
* Returns the result set as an object.
|
||||||
*
|
*
|
||||||
* Overriden by driver result classes.
|
* Overridden by driver result classes.
|
||||||
*
|
*
|
||||||
* @param string $class_name
|
* @param string $class_name
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
protected function _fetch_object($class_name = 'stdClass')
|
protected function _fetch_object($class_name = 'stdClass')
|
||||||
{
|
{
|
||||||
return array();
|
return new $class_name();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file DB_result.php */
|
|
||||||
/* Location: ./system/database/DB_result.php */
|
|
59
system/database/DB_utility.php
Executable file → Normal file
59
system/database/DB_utility.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
abstract class CI_DB_utility {
|
abstract class CI_DB_utility {
|
||||||
|
|
||||||
@ -76,7 +87,7 @@ abstract class CI_DB_utility {
|
|||||||
public function __construct(&$db)
|
public function __construct(&$db)
|
||||||
{
|
{
|
||||||
$this->db =& $db;
|
$this->db =& $db;
|
||||||
log_message('debug', 'Database Utility Class Initialized');
|
log_message('info', 'Database Utility Class Initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -238,16 +249,17 @@ abstract class CI_DB_utility {
|
|||||||
$out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim;
|
$out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim;
|
||||||
}
|
}
|
||||||
|
|
||||||
$out = substr(rtrim($out), 0, -strlen($delim)).$newline;
|
$out = substr($out, 0, -strlen($delim)).$newline;
|
||||||
|
|
||||||
// Next blast through the result array and build out the rows
|
// Next blast through the result array and build out the rows
|
||||||
while ($row = $query->unbuffered_row('array'))
|
while ($row = $query->unbuffered_row('array'))
|
||||||
{
|
{
|
||||||
|
$line = array();
|
||||||
foreach ($row as $item)
|
foreach ($row as $item)
|
||||||
{
|
{
|
||||||
$out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure.$delim;
|
$line[] = $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure;
|
||||||
}
|
}
|
||||||
$out = substr(rtrim($out), 0, -strlen($delim)).$newline;
|
$out .= implode($delim, $line).$newline;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
@ -305,7 +317,7 @@ abstract class CI_DB_utility {
|
|||||||
* Database Backup
|
* Database Backup
|
||||||
*
|
*
|
||||||
* @param array $params
|
* @param array $params
|
||||||
* @return void
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function backup($params = array())
|
public function backup($params = array())
|
||||||
{
|
{
|
||||||
@ -410,6 +422,3 @@ abstract class CI_DB_utility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file DB_utility.php */
|
|
||||||
/* Location: ./system/database/DB_utility.php */
|
|
110
system/database/drivers/cubrid/cubrid_driver.php
Executable file → Normal file
110
system/database/drivers/cubrid/cubrid_driver.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 2.1
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 2.1.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -37,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author Esen Sagynov
|
* @author Esen Sagynov
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_cubrid_driver extends CI_DB {
|
class CI_DB_cubrid_driver extends CI_DB {
|
||||||
|
|
||||||
@ -152,10 +163,6 @@ class CI_DB_cubrid_driver extends CI_DB {
|
|||||||
{
|
{
|
||||||
return $this->data_cache['version'];
|
return $this->data_cache['version'];
|
||||||
}
|
}
|
||||||
elseif ( ! $this->conn_id)
|
|
||||||
{
|
|
||||||
$this->initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( ! $this->conn_id OR ($version = cubrid_get_server_info($this->conn_id)) === FALSE)
|
return ( ! $this->conn_id OR ($version = cubrid_get_server_info($this->conn_id)) === FALSE)
|
||||||
? FALSE
|
? FALSE
|
||||||
@ -180,25 +187,17 @@ class CI_DB_cubrid_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* Begin Transaction
|
* Begin Transaction
|
||||||
*
|
*
|
||||||
* @param bool $test_mode
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_begin($test_mode = FALSE)
|
protected function _trans_begin()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
if (($autocommit = cubrid_get_autocommit($this->conn_id)) === NULL)
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
{
|
||||||
return TRUE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
elseif ($autocommit === TRUE)
|
||||||
// Reset the transaction failure flag.
|
|
||||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
|
||||||
// even if the queries produce a successful result.
|
|
||||||
$this->_trans_failure = ($test_mode === TRUE);
|
|
||||||
|
|
||||||
if (cubrid_get_autocommit($this->conn_id))
|
|
||||||
{
|
{
|
||||||
cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_FALSE);
|
return cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -211,19 +210,16 @@ class CI_DB_cubrid_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_commit()
|
protected function _trans_commit()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
if ( ! cubrid_commit($this->conn_id))
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
{
|
||||||
return TRUE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cubrid_commit($this->conn_id);
|
|
||||||
|
|
||||||
if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
|
if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
|
||||||
{
|
{
|
||||||
cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
|
return cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -236,16 +232,13 @@ class CI_DB_cubrid_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_rollback()
|
protected function _trans_rollback()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
if ( ! cubrid_rollback($this->conn_id))
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
{
|
||||||
return TRUE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cubrid_rollback($this->conn_id);
|
|
||||||
|
|
||||||
if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
|
if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
|
||||||
{
|
{
|
||||||
cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
|
cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
|
||||||
@ -257,21 +250,14 @@ class CI_DB_cubrid_driver extends CI_DB {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform-dependant string escape
|
* Platform-dependent string escape
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function _escape_str($str)
|
protected function _escape_str($str)
|
||||||
{
|
{
|
||||||
if (function_exists('cubrid_real_escape_string') &&
|
return cubrid_real_escape_string($str, $this->conn_id);
|
||||||
(is_resource($this->conn_id)
|
|
||||||
OR (get_resource_type($this->conn_id) === 'Unknown' && preg_match('/Resource id #/', strval($this->conn_id)))))
|
|
||||||
{
|
|
||||||
return cubrid_real_escape_string($str, $this->conn_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return addslashes($str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -343,13 +329,8 @@ class CI_DB_cubrid_driver extends CI_DB {
|
|||||||
* @param string $table
|
* @param string $table
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function field_data($table = '')
|
public function field_data($table)
|
||||||
{
|
{
|
||||||
if ($table === '')
|
|
||||||
{
|
|
||||||
return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
|
if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -380,7 +361,7 @@ class CI_DB_cubrid_driver extends CI_DB {
|
|||||||
* Error
|
* Error
|
||||||
*
|
*
|
||||||
* Returns an array containing code and message of the last
|
* Returns an array containing code and message of the last
|
||||||
* database error that has occured.
|
* database error that has occurred.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -422,6 +403,3 @@ class CI_DB_cubrid_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file cubrid_driver.php */
|
|
||||||
/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */
|
|
51
system/database/drivers/cubrid/cubrid_forge.php
Executable file → Normal file
51
system/database/drivers/cubrid/cubrid_forge.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 2.1
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 2.1.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author Esen Sagynov
|
* @author Esen Sagynov
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_cubrid_forge extends CI_DB_forge {
|
class CI_DB_cubrid_forge extends CI_DB_forge {
|
||||||
|
|
||||||
@ -167,6 +178,9 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
|
|||||||
$attributes['TYPE'] = 'INTEGER';
|
$attributes['TYPE'] = 'INTEGER';
|
||||||
$attributes['UNSIGNED'] = FALSE;
|
$attributes['UNSIGNED'] = FALSE;
|
||||||
return;
|
return;
|
||||||
|
case 'LONGTEXT':
|
||||||
|
$attributes['TYPE'] = 'STRING';
|
||||||
|
return;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,6 +228,3 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file cubrid_forge.php */
|
|
||||||
/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */
|
|
49
system/database/drivers/cubrid/cubrid_result.php
Executable file → Normal file
49
system/database/drivers/cubrid/cubrid_result.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 2.1
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 2.1.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -33,8 +44,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author Esen Sagynov
|
* @author Esen Sagynov
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
* @since 2.1
|
|
||||||
*/
|
*/
|
||||||
class CI_DB_cubrid_result extends CI_DB_result {
|
class CI_DB_cubrid_result extends CI_DB_result {
|
||||||
|
|
||||||
@ -165,6 +175,3 @@ class CI_DB_cubrid_result extends CI_DB_result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file cubrid_result.php */
|
|
||||||
/* Location: ./system/database/drivers/cubrid/cubrid_result.php */
|
|
48
system/database/drivers/cubrid/cubrid_utility.php
Executable file → Normal file
48
system/database/drivers/cubrid/cubrid_utility.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 2.1
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 2.1.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author Esen Sagynov
|
* @author Esen Sagynov
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_cubrid_utility extends CI_DB_utility {
|
class CI_DB_cubrid_utility extends CI_DB_utility {
|
||||||
|
|
||||||
@ -66,6 +77,3 @@ class CI_DB_cubrid_utility extends CI_DB_utility {
|
|||||||
return $this->db->display_error('db_unsupported_feature');
|
return $this->db->display_error('db_unsupported_feature');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file cubrid_utility.php */
|
|
||||||
/* Location: ./system/database/drivers/cubrid/cubrid_utility.php */
|
|
3
system/database/drivers/cubrid/index.html
Executable file → Normal file
3
system/database/drivers/cubrid/index.html
Executable file → Normal file
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>403 Forbidden</title>
|
<title>403 Forbidden</title>
|
||||||
@ -7,4 +8,4 @@
|
|||||||
<p>Directory access is forbidden.</p>
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
114
system/database/drivers/ibase/ibase_driver.php
Executable file → Normal file
114
system/database/drivers/ibase/ibase_driver.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 3.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 3.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -37,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_ibase_driver extends CI_DB {
|
class CI_DB_ibase_driver extends CI_DB {
|
||||||
|
|
||||||
@ -115,7 +126,7 @@ class CI_DB_ibase_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
protected function _execute($sql)
|
protected function _execute($sql)
|
||||||
{
|
{
|
||||||
return ibase_query($this->conn_id, $sql);
|
return ibase_query(isset($this->_ibase_trans) ? $this->_ibase_trans : $this->conn_id, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -123,24 +134,16 @@ class CI_DB_ibase_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* Begin Transaction
|
* Begin Transaction
|
||||||
*
|
*
|
||||||
* @param bool $test_mode
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_begin($test_mode = FALSE)
|
protected function _trans_begin()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
if (($trans_handle = ibase_trans($this->conn_id)) === FALSE)
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
{
|
||||||
return TRUE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the transaction failure flag.
|
$this->_ibase_trans = $trans_handle;
|
||||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
|
||||||
// even if the queries produce a successful result.
|
|
||||||
$this->_trans_failure = ($test_mode === TRUE);
|
|
||||||
|
|
||||||
$this->_ibase_trans = ibase_trans($this->conn_id);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,15 +154,15 @@ class CI_DB_ibase_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_commit()
|
protected function _trans_commit()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
if (ibase_commit($this->_ibase_trans))
|
||||||
if ( ! $this->trans_enabled OR $this->_trans->depth > 0)
|
|
||||||
{
|
{
|
||||||
|
$this->_ibase_trans = NULL;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ibase_commit($this->_ibase_trans);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -169,15 +172,15 @@ class CI_DB_ibase_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_rollback()
|
protected function _trans_rollback()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
if (ibase_rollback($this->_ibase_trans))
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
{
|
||||||
|
$this->_ibase_trans = NULL;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ibase_rollback($this->_ibase_trans);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -219,11 +222,11 @@ class CI_DB_ibase_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
protected function _list_tables($prefix_limit = FALSE)
|
protected function _list_tables($prefix_limit = FALSE)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT "RDB$RELATION_NAME" FROM "RDB$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\'';
|
$sql = 'SELECT TRIM("RDB$RELATION_NAME") AS TABLE_NAME FROM "RDB$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\'';
|
||||||
|
|
||||||
if ($prefix_limit !== FALSE && $this->dbprefix !== '')
|
if ($prefix_limit !== FALSE && $this->dbprefix !== '')
|
||||||
{
|
{
|
||||||
return $sql.' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' "
|
return $sql.' AND TRIM("RDB$RELATION_NAME") AS TABLE_NAME LIKE \''.$this->escape_like_str($this->dbprefix)."%' "
|
||||||
.sprintf($this->_like_escape_str, $this->_like_escape_chr);
|
.sprintf($this->_like_escape_str, $this->_like_escape_chr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +245,7 @@ class CI_DB_ibase_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
protected function _list_columns($table = '')
|
protected function _list_columns($table = '')
|
||||||
{
|
{
|
||||||
return 'SELECT "RDB$FIELD_NAME" FROM "RDB$RELATION_FIELDS" WHERE "RDB$RELATION_NAME" = '.$this->escape($table);
|
return 'SELECT TRIM("RDB$FIELD_NAME") AS COLUMN_NAME FROM "RDB$RELATION_FIELDS" WHERE "RDB$RELATION_NAME" = '.$this->escape($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -253,13 +256,8 @@ class CI_DB_ibase_driver extends CI_DB {
|
|||||||
* @param string $table
|
* @param string $table
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function field_data($table = '')
|
public function field_data($table)
|
||||||
{
|
{
|
||||||
if ($table === '')
|
|
||||||
{
|
|
||||||
return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = 'SELECT "rfields"."RDB$FIELD_NAME" AS "name",
|
$sql = 'SELECT "rfields"."RDB$FIELD_NAME" AS "name",
|
||||||
CASE "fields"."RDB$FIELD_TYPE"
|
CASE "fields"."RDB$FIELD_TYPE"
|
||||||
WHEN 7 THEN \'SMALLINT\'
|
WHEN 7 THEN \'SMALLINT\'
|
||||||
@ -296,7 +294,7 @@ class CI_DB_ibase_driver extends CI_DB {
|
|||||||
* Error
|
* Error
|
||||||
*
|
*
|
||||||
* Returns an array containing code and message of the last
|
* Returns an array containing code and message of the last
|
||||||
* database error that has occured.
|
* database error that has occurred.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -385,6 +383,23 @@ class CI_DB_ibase_driver extends CI_DB {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert batch statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific insert string from the supplied data.
|
||||||
|
*
|
||||||
|
* @param string $table Table name
|
||||||
|
* @param array $keys INSERT keys
|
||||||
|
* @param array $values INSERT values
|
||||||
|
* @return string|bool
|
||||||
|
*/
|
||||||
|
protected function _insert_batch($table, $keys, $values)
|
||||||
|
{
|
||||||
|
return ($this->db_debug) ? $this->display_error('db_unsupported_feature') : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close DB Connection
|
* Close DB Connection
|
||||||
*
|
*
|
||||||
@ -396,6 +411,3 @@ class CI_DB_ibase_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file ibase_driver.php */
|
|
||||||
/* Location: ./system/database/drivers/ibase/ibase_driver.php */
|
|
52
system/database/drivers/ibase/ibase_forge.php
Executable file → Normal file
52
system/database/drivers/ibase/ibase_forge.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 3.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 3.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_ibase_forge extends CI_DB_forge {
|
class CI_DB_ibase_forge extends CI_DB_forge {
|
||||||
|
|
||||||
@ -80,7 +91,7 @@ class CI_DB_ibase_forge extends CI_DB_forge {
|
|||||||
* Create database
|
* Create database
|
||||||
*
|
*
|
||||||
* @param string $db_name
|
* @param string $db_name
|
||||||
* @return string
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function create_database($db_name)
|
public function create_database($db_name)
|
||||||
{
|
{
|
||||||
@ -100,7 +111,7 @@ class CI_DB_ibase_forge extends CI_DB_forge {
|
|||||||
* @param string $db_name (ignored)
|
* @param string $db_name (ignored)
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function drop_database($db_name = '')
|
public function drop_database($db_name)
|
||||||
{
|
{
|
||||||
if ( ! ibase_drop_db($this->conn_id))
|
if ( ! ibase_drop_db($this->conn_id))
|
||||||
{
|
{
|
||||||
@ -238,6 +249,3 @@ class CI_DB_ibase_forge extends CI_DB_forge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file ibase_forge.php */
|
|
||||||
/* Location: ./system/database/drivers/ibase/ibase_forge.php */
|
|
49
system/database/drivers/ibase/ibase_result.php
Executable file → Normal file
49
system/database/drivers/ibase/ibase_result.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 3.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -33,8 +44,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
* @since 3.0
|
|
||||||
*/
|
*/
|
||||||
class CI_DB_ibase_result extends CI_DB_result {
|
class CI_DB_ibase_result extends CI_DB_result {
|
||||||
|
|
||||||
@ -149,6 +159,3 @@ class CI_DB_ibase_result extends CI_DB_result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file ibase_result.php */
|
|
||||||
/* Location: ./system/database/drivers/ibase/ibase_result.php */
|
|
48
system/database/drivers/ibase/ibase_utility.php
Executable file → Normal file
48
system/database/drivers/ibase/ibase_utility.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 3.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 3.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_ibase_utility extends CI_DB_utility {
|
class CI_DB_ibase_utility extends CI_DB_utility {
|
||||||
|
|
||||||
@ -56,6 +67,3 @@ class CI_DB_ibase_utility extends CI_DB_utility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file ibase_utility.php */
|
|
||||||
/* Location: ./system/database/drivers/ibase/ibase_utility.php */
|
|
3
system/database/drivers/ibase/index.html
Executable file → Normal file
3
system/database/drivers/ibase/index.html
Executable file → Normal file
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>403 Forbidden</title>
|
<title>403 Forbidden</title>
|
||||||
@ -7,4 +8,4 @@
|
|||||||
<p>Directory access is forbidden.</p>
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
3
system/database/drivers/index.html
Executable file → Normal file
3
system/database/drivers/index.html
Executable file → Normal file
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>403 Forbidden</title>
|
<title>403 Forbidden</title>
|
||||||
@ -7,4 +8,4 @@
|
|||||||
<p>Directory access is forbidden.</p>
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
3
system/database/drivers/mssql/index.html
Executable file → Normal file
3
system/database/drivers/mssql/index.html
Executable file → Normal file
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>403 Forbidden</title>
|
<title>403 Forbidden</title>
|
||||||
@ -7,4 +8,4 @@
|
|||||||
<p>Directory access is forbidden.</p>
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
114
system/database/drivers/mssql/mssql_driver.php
Executable file → Normal file
114
system/database/drivers/mssql/mssql_driver.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.3.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -37,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_mssql_driver extends CI_DB {
|
class CI_DB_mssql_driver extends CI_DB {
|
||||||
|
|
||||||
@ -143,10 +154,11 @@ class CI_DB_mssql_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note: Escaping is required in the event that the DB name
|
// Note: Escaping is required in the event that the DB name
|
||||||
// contains reserved characters
|
// contains reserved characters.
|
||||||
if (mssql_select_db($this->escape_identifiers($database), $this->conn_id))
|
if (mssql_select_db('['.$database.']', $this->conn_id))
|
||||||
{
|
{
|
||||||
$this->database = $database;
|
$this->database = $database;
|
||||||
|
$this->data_cache = array();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,22 +183,10 @@ class CI_DB_mssql_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* Begin Transaction
|
* Begin Transaction
|
||||||
*
|
*
|
||||||
* @param bool $test_mode
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_begin($test_mode = FALSE)
|
protected function _trans_begin()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset the transaction failure flag.
|
|
||||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
|
||||||
// even if the queries produce a successful result.
|
|
||||||
$this->_trans_failure = ($test_mode === TRUE);
|
|
||||||
|
|
||||||
return $this->simple_query('BEGIN TRAN');
|
return $this->simple_query('BEGIN TRAN');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,14 +197,8 @@ class CI_DB_mssql_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_commit()
|
protected function _trans_commit()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->simple_query('COMMIT TRAN');
|
return $this->simple_query('COMMIT TRAN');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,14 +209,8 @@ class CI_DB_mssql_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_rollback()
|
protected function _trans_rollback()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->simple_query('ROLLBACK TRAN');
|
return $this->simple_query('ROLLBACK TRAN');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,7 +268,7 @@ class CI_DB_mssql_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
protected function _version()
|
protected function _version()
|
||||||
{
|
{
|
||||||
return 'SELECT @@VERSION AS ver';
|
return "SELECT SERVERPROPERTY('ProductVersion') AS ver";
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -333,13 +321,8 @@ class CI_DB_mssql_driver extends CI_DB {
|
|||||||
* @param string $table
|
* @param string $table
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function field_data($table = '')
|
public function field_data($table)
|
||||||
{
|
{
|
||||||
if ($table === '')
|
|
||||||
{
|
|
||||||
return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql = 'SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, COLUMN_DEFAULT
|
$sql = 'SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, COLUMN_DEFAULT
|
||||||
FROM INFORMATION_SCHEMA.Columns
|
FROM INFORMATION_SCHEMA.Columns
|
||||||
WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table));
|
WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table));
|
||||||
@ -369,15 +352,25 @@ class CI_DB_mssql_driver extends CI_DB {
|
|||||||
* Error
|
* Error
|
||||||
*
|
*
|
||||||
* Returns an array containing code and message of the last
|
* Returns an array containing code and message of the last
|
||||||
* database error that has occured.
|
* database error that has occurred.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function error()
|
public function error()
|
||||||
{
|
{
|
||||||
$query = $this->query('SELECT @@ERROR AS code');
|
// We need this because the error info is discarded by the
|
||||||
$query = $query->row();
|
// server the first time you request it, and query() already
|
||||||
return array('code' => $query->code, 'message' => mssql_get_last_message());
|
// calls error() once for logging purposes when a query fails.
|
||||||
|
static $error = array('code' => 0, 'message' => NULL);
|
||||||
|
|
||||||
|
$message = mssql_get_last_message();
|
||||||
|
if ( ! empty($message))
|
||||||
|
{
|
||||||
|
$error['code'] = $this->query('SELECT @@ERROR AS code')->row()->code;
|
||||||
|
$error['message'] = $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -460,7 +453,7 @@ class CI_DB_mssql_driver extends CI_DB {
|
|||||||
$sql = trim(substr($sql, 0, strrpos($sql, $orderby)));
|
$sql = trim(substr($sql, 0, strrpos($sql, $orderby)));
|
||||||
|
|
||||||
// Get the fields to select from our subquery, so that we can avoid CI_rownum appearing in the actual results
|
// Get the fields to select from our subquery, so that we can avoid CI_rownum appearing in the actual results
|
||||||
if (count($this->qb_select) === 0)
|
if (count($this->qb_select) === 0 OR strpos(implode(',', $this->qb_select), '*') !== FALSE)
|
||||||
{
|
{
|
||||||
$select = '*'; // Inevitable
|
$select = '*'; // Inevitable
|
||||||
}
|
}
|
||||||
@ -507,7 +500,7 @@ class CI_DB_mssql_driver extends CI_DB {
|
|||||||
return parent::_insert_batch($table, $keys, $values);
|
return parent::_insert_batch($table, $keys, $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
|
return ($this->db_debug) ? $this->display_error('db_unsupported_feature') : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -523,6 +516,3 @@ class CI_DB_mssql_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file mssql_driver.php */
|
|
||||||
/* Location: ./system/database/drivers/mssql/mssql_driver.php */
|
|
55
system/database/drivers/mssql/mssql_forge.php
Executable file → Normal file
55
system/database/drivers/mssql/mssql_forge.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.3.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -29,9 +40,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
/**
|
/**
|
||||||
* MS SQL Forge Class
|
* MS SQL Forge Class
|
||||||
*
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_mssql_forge extends CI_DB_forge {
|
class CI_DB_mssql_forge extends CI_DB_forge {
|
||||||
|
|
||||||
@ -100,6 +113,11 @@ class CI_DB_mssql_forge extends CI_DB_forge {
|
|||||||
*/
|
*/
|
||||||
protected function _attr_type(&$attributes)
|
protected function _attr_type(&$attributes)
|
||||||
{
|
{
|
||||||
|
if (isset($attributes['CONSTRAINT']) && strpos($attributes['TYPE'], 'INT') !== FALSE)
|
||||||
|
{
|
||||||
|
unset($attributes['CONSTRAINT']);
|
||||||
|
}
|
||||||
|
|
||||||
switch (strtoupper($attributes['TYPE']))
|
switch (strtoupper($attributes['TYPE']))
|
||||||
{
|
{
|
||||||
case 'MEDIUMINT':
|
case 'MEDIUMINT':
|
||||||
@ -131,6 +149,3 @@ class CI_DB_mssql_forge extends CI_DB_forge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file mssql_forge.php */
|
|
||||||
/* Location: ./system/database/drivers/mssql/mssql_forge.php */
|
|
53
system/database/drivers/mssql/mssql_result.php
Executable file → Normal file
53
system/database/drivers/mssql/mssql_result.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.3.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,10 +42,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* This class extends the parent result class: CI_DB_result
|
* This class extends the parent result class: CI_DB_result
|
||||||
*
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
* @since 1.3
|
|
||||||
*/
|
*/
|
||||||
class CI_DB_mssql_result extends CI_DB_result {
|
class CI_DB_mssql_result extends CI_DB_result {
|
||||||
|
|
||||||
@ -95,7 +107,7 @@ class CI_DB_mssql_result extends CI_DB_result {
|
|||||||
public function field_data()
|
public function field_data()
|
||||||
{
|
{
|
||||||
$retval = array();
|
$retval = array();
|
||||||
for ($i = 0, $c = $this->num_field(); $i < $c; $i++)
|
for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
|
||||||
{
|
{
|
||||||
$field = mssql_fetch_field($this->result_id, $i);
|
$field = mssql_fetch_field($this->result_id, $i);
|
||||||
|
|
||||||
@ -184,6 +196,3 @@ class CI_DB_mssql_result extends CI_DB_result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file mssql_result.php */
|
|
||||||
/* Location: ./system/database/drivers/mssql/mssql_result.php */
|
|
50
system/database/drivers/mssql/mssql_utility.php
Executable file → Normal file
50
system/database/drivers/mssql/mssql_utility.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.3.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -29,9 +40,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
/**
|
/**
|
||||||
* MS SQL Utility Class
|
* MS SQL Utility Class
|
||||||
*
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_mssql_utility extends CI_DB_utility {
|
class CI_DB_mssql_utility extends CI_DB_utility {
|
||||||
|
|
||||||
@ -62,6 +75,3 @@ class CI_DB_mssql_utility extends CI_DB_utility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file mssql_utility.php */
|
|
||||||
/* Location: ./system/database/drivers/mssql/mssql_utility.php */
|
|
3
system/database/drivers/mysql/index.html
Executable file → Normal file
3
system/database/drivers/mysql/index.html
Executable file → Normal file
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>403 Forbidden</title>
|
<title>403 Forbidden</title>
|
||||||
@ -7,4 +8,4 @@
|
|||||||
<p>Directory access is forbidden.</p>
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
132
system/database/drivers/mysql/mysql_driver.php
Executable file → Normal file
132
system/database/drivers/mysql/mysql_driver.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -37,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_mysql_driver extends CI_DB {
|
class CI_DB_mysql_driver extends CI_DB {
|
||||||
|
|
||||||
@ -73,7 +84,7 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public $stricton = FALSE;
|
public $stricton;
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
@ -121,8 +132,8 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
|
|
||||||
// Error suppression is necessary mostly due to PHP 5.5+ issuing E_DEPRECATED messages
|
// Error suppression is necessary mostly due to PHP 5.5+ issuing E_DEPRECATED messages
|
||||||
$this->conn_id = ($persistent === TRUE)
|
$this->conn_id = ($persistent === TRUE)
|
||||||
? @mysql_pconnect($this->hostname, $this->username, $this->password, $client_flags)
|
? mysql_pconnect($this->hostname, $this->username, $this->password, $client_flags)
|
||||||
: @mysql_connect($this->hostname, $this->username, $this->password, TRUE, $client_flags);
|
: mysql_connect($this->hostname, $this->username, $this->password, TRUE, $client_flags);
|
||||||
|
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
|
|
||||||
@ -136,9 +147,26 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
: FALSE;
|
: FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->stricton && is_resource($this->conn_id))
|
if (isset($this->stricton) && is_resource($this->conn_id))
|
||||||
{
|
{
|
||||||
$this->simple_query('SET SESSION sql_mode="STRICT_ALL_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;
|
||||||
@ -180,6 +208,7 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
if (mysql_select_db($database, $this->conn_id))
|
if (mysql_select_db($database, $this->conn_id))
|
||||||
{
|
{
|
||||||
$this->database = $database;
|
$this->database = $database;
|
||||||
|
$this->data_cache = array();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,10 +241,6 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
{
|
{
|
||||||
return $this->data_cache['version'];
|
return $this->data_cache['version'];
|
||||||
}
|
}
|
||||||
elseif ( ! $this->conn_id)
|
|
||||||
{
|
|
||||||
$this->initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! $this->conn_id OR ($version = mysql_get_server_info($this->conn_id)) === FALSE)
|
if ( ! $this->conn_id OR ($version = mysql_get_server_info($this->conn_id)) === FALSE)
|
||||||
{
|
{
|
||||||
@ -265,25 +290,12 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* Begin Transaction
|
* Begin Transaction
|
||||||
*
|
*
|
||||||
* @param bool $test_mode
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_begin($test_mode = FALSE)
|
protected function _trans_begin()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset the transaction failure flag.
|
|
||||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
|
||||||
// even if the queries produce a successful result.
|
|
||||||
$this->_trans_failure = ($test_mode === TRUE);
|
|
||||||
|
|
||||||
$this->simple_query('SET AUTOCOMMIT=0');
|
$this->simple_query('SET AUTOCOMMIT=0');
|
||||||
$this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
|
return $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -293,17 +305,15 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_commit()
|
protected function _trans_commit()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
if ($this->simple_query('COMMIT'))
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
{
|
||||||
|
$this->simple_query('SET AUTOCOMMIT=1');
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->simple_query('COMMIT');
|
return FALSE;
|
||||||
$this->simple_query('SET AUTOCOMMIT=1');
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -313,32 +323,28 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_rollback()
|
protected function _trans_rollback()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
if ($this->simple_query('ROLLBACK'))
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
{
|
||||||
|
$this->simple_query('SET AUTOCOMMIT=1');
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->simple_query('ROLLBACK');
|
return FALSE;
|
||||||
$this->simple_query('SET AUTOCOMMIT=1');
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform-dependant string escape
|
* Platform-dependent string escape
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function _escape_str($str)
|
protected function _escape_str($str)
|
||||||
{
|
{
|
||||||
return is_resource($this->conn_id)
|
return mysql_real_escape_string($str, $this->conn_id);
|
||||||
? mysql_real_escape_string($str, $this->conn_id)
|
|
||||||
: addslashes($str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -410,13 +416,8 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
* @param string $table
|
* @param string $table
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function field_data($table = '')
|
public function field_data($table)
|
||||||
{
|
{
|
||||||
if ($table === '')
|
|
||||||
{
|
|
||||||
return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
|
if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -447,7 +448,7 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
* Error
|
* Error
|
||||||
*
|
*
|
||||||
* Returns an array containing code and message of the last
|
* Returns an array containing code and message of the last
|
||||||
* database error that has occured.
|
* database error that has occurred.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -491,6 +492,3 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file mysql_driver.php */
|
|
||||||
/* Location: ./system/database/drivers/mysql/mysql_driver.php */
|
|
52
system/database/drivers/mysql/mysql_forge.php
Executable file → Normal file
52
system/database/drivers/mysql/mysql_forge.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_mysql_forge extends CI_DB_forge {
|
class CI_DB_mysql_forge extends CI_DB_forge {
|
||||||
|
|
||||||
@ -77,7 +88,7 @@ class CI_DB_mysql_forge extends CI_DB_forge {
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $_null = 'NULL';
|
protected $_null = 'NULL';
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
@ -174,6 +185,7 @@ class CI_DB_mysql_forge extends CI_DB_forge {
|
|||||||
$extra_clause = ' FIRST';
|
$extra_clause = ' FIRST';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $this->db->escape_identifiers($field['name'])
|
return $this->db->escape_identifiers($field['name'])
|
||||||
.(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
|
.(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
|
||||||
.' '.$field['type'].$field['length']
|
.' '.$field['type'].$field['length']
|
||||||
@ -182,6 +194,7 @@ class CI_DB_mysql_forge extends CI_DB_forge {
|
|||||||
.$field['default']
|
.$field['default']
|
||||||
.$field['auto_increment']
|
.$field['auto_increment']
|
||||||
.$field['unique']
|
.$field['unique']
|
||||||
|
.(empty($field['comment']) ? '' : ' COMMENT '.$field['comment'])
|
||||||
.$extra_clause;
|
.$extra_clause;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,6 +241,3 @@ class CI_DB_mysql_forge extends CI_DB_forge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file mysql_forge.php */
|
|
||||||
/* Location: ./system/database/drivers/mysql/mysql_forge.php */
|
|
49
system/database/drivers/mysql/mysql_result.php
Executable file → Normal file
49
system/database/drivers/mysql/mysql_result.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -33,8 +44,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
* @since 1.0
|
|
||||||
*/
|
*/
|
||||||
class CI_DB_mysql_result extends CI_DB_result {
|
class CI_DB_mysql_result extends CI_DB_result {
|
||||||
|
|
||||||
@ -187,6 +197,3 @@ class CI_DB_mysql_result extends CI_DB_result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file mysql_result.php */
|
|
||||||
/* Location: ./system/database/drivers/mysql/mysql_result.php */
|
|
48
system/database/drivers/mysql/mysql_utility.php
Executable file → Normal file
48
system/database/drivers/mysql/mysql_utility.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_mysql_utility extends CI_DB_utility {
|
class CI_DB_mysql_utility extends CI_DB_utility {
|
||||||
|
|
||||||
@ -198,6 +209,3 @@ class CI_DB_mysql_utility extends CI_DB_utility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file mysql_utility.php */
|
|
||||||
/* Location: ./system/database/drivers/mysql/mysql_utility.php */
|
|
3
system/database/drivers/mysqli/index.html
Executable file → Normal file
3
system/database/drivers/mysqli/index.html
Executable file → Normal file
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>403 Forbidden</title>
|
<title>403 Forbidden</title>
|
||||||
@ -7,4 +8,4 @@
|
|||||||
<p>Directory access is forbidden.</p>
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
229
system/database/drivers/mysqli/mysqli_driver.php
Executable file → Normal file
229
system/database/drivers/mysqli/mysqli_driver.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.3.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -37,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_mysqli_driver extends CI_DB {
|
class CI_DB_mysqli_driver extends CI_DB {
|
||||||
|
|
||||||
@ -73,7 +84,7 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public $stricton = FALSE;
|
public $stricton;
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
@ -86,29 +97,128 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MySQLi object
|
||||||
|
*
|
||||||
|
* Has to be preserved without being assigned to $conn_id.
|
||||||
|
*
|
||||||
|
* @var MySQLi
|
||||||
|
*/
|
||||||
|
protected $_mysqli;
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database connection
|
* Database connection
|
||||||
*
|
*
|
||||||
* @param bool $persistent
|
* @param bool $persistent
|
||||||
* @return object
|
* @return object
|
||||||
* @todo SSL support
|
|
||||||
*/
|
*/
|
||||||
public function db_connect($persistent = FALSE)
|
public function db_connect($persistent = FALSE)
|
||||||
{
|
{
|
||||||
// Persistent connection support was added in PHP 5.3.0
|
// Do we have a socket path?
|
||||||
$hostname = ($persistent === TRUE && is_php('5.3'))
|
if ($this->hostname[0] === '/')
|
||||||
? 'p:'.$this->hostname : $this->hostname;
|
|
||||||
$port = empty($this->port) ? NULL : $this->port;
|
|
||||||
$client_flags = ($this->compress === TRUE) ? MYSQLI_CLIENT_COMPRESS : 0;
|
|
||||||
$mysqli = mysqli_init();
|
|
||||||
|
|
||||||
if ($this->stricton)
|
|
||||||
{
|
{
|
||||||
$mysqli->options(MYSQLI_INIT_COMMAND, 'SET SESSION sql_mode="STRICT_ALL_TABLES"');
|
$hostname = NULL;
|
||||||
|
$port = NULL;
|
||||||
|
$socket = $this->hostname;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$hostname = ($persistent === TRUE)
|
||||||
|
? 'p:'.$this->hostname : $this->hostname;
|
||||||
|
$port = empty($this->port) ? NULL : $this->port;
|
||||||
|
$socket = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, NULL, $client_flags)
|
$client_flags = ($this->compress === TRUE) ? MYSQLI_CLIENT_COMPRESS : 0;
|
||||||
? $mysqli : FALSE;
|
$this->_mysqli = mysqli_init();
|
||||||
|
|
||||||
|
$this->_mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 10);
|
||||||
|
|
||||||
|
if (isset($this->stricton))
|
||||||
|
{
|
||||||
|
if ($this->stricton)
|
||||||
|
{
|
||||||
|
$this->_mysqli->options(MYSQLI_INIT_COMMAND, 'SET SESSION sql_mode = CONCAT(@@sql_mode, ",", "STRICT_ALL_TABLES")');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->_mysqli->options(MYSQLI_INIT_COMMAND,
|
||||||
|
'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 (is_array($this->encrypt))
|
||||||
|
{
|
||||||
|
$ssl = array();
|
||||||
|
empty($this->encrypt['ssl_key']) OR $ssl['key'] = $this->encrypt['ssl_key'];
|
||||||
|
empty($this->encrypt['ssl_cert']) OR $ssl['cert'] = $this->encrypt['ssl_cert'];
|
||||||
|
empty($this->encrypt['ssl_ca']) OR $ssl['ca'] = $this->encrypt['ssl_ca'];
|
||||||
|
empty($this->encrypt['ssl_capath']) OR $ssl['capath'] = $this->encrypt['ssl_capath'];
|
||||||
|
empty($this->encrypt['ssl_cipher']) OR $ssl['cipher'] = $this->encrypt['ssl_cipher'];
|
||||||
|
|
||||||
|
if (isset($this->encrypt['ssl_verify']))
|
||||||
|
{
|
||||||
|
$client_flags |= MYSQLI_CLIENT_SSL;
|
||||||
|
|
||||||
|
if ($this->encrypt['ssl_verify'])
|
||||||
|
{
|
||||||
|
defined('MYSQLI_OPT_SSL_VERIFY_SERVER_CERT') && $this->_mysqli->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, TRUE);
|
||||||
|
}
|
||||||
|
// Apparently (when it exists), setting MYSQLI_OPT_SSL_VERIFY_SERVER_CERT
|
||||||
|
// to FALSE didn't do anything, so PHP 5.6.16 introduced yet another
|
||||||
|
// constant ...
|
||||||
|
//
|
||||||
|
// https://secure.php.net/ChangeLog-5.php#5.6.16
|
||||||
|
// https://bugs.php.net/bug.php?id=68344
|
||||||
|
elseif (defined('MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT'))
|
||||||
|
{
|
||||||
|
$client_flags |= MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty($ssl))
|
||||||
|
{
|
||||||
|
$client_flags |= MYSQLI_CLIENT_SSL;
|
||||||
|
$this->_mysqli->ssl_set(
|
||||||
|
isset($ssl['key']) ? $ssl['key'] : NULL,
|
||||||
|
isset($ssl['cert']) ? $ssl['cert'] : NULL,
|
||||||
|
isset($ssl['ca']) ? $ssl['ca'] : NULL,
|
||||||
|
isset($ssl['capath']) ? $ssl['capath'] : NULL,
|
||||||
|
isset($ssl['cipher']) ? $ssl['cipher'] : NULL
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->_mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, $socket, $client_flags))
|
||||||
|
{
|
||||||
|
// Prior to version 5.7.3, MySQL silently downgrades to an unencrypted connection if SSL setup fails
|
||||||
|
if (
|
||||||
|
($client_flags & MYSQLI_CLIENT_SSL)
|
||||||
|
&& version_compare($this->_mysqli->client_info, '5.7.3', '<=')
|
||||||
|
&& empty($this->_mysqli->query("SHOW STATUS LIKE 'ssl_cipher'")->fetch_object()->Value)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$this->_mysqli->close();
|
||||||
|
$message = 'MySQLi was configured for an SSL connection, but got an unencrypted connection instead!';
|
||||||
|
log_message('error', $message);
|
||||||
|
return ($this->db_debug) ? $this->display_error($message, '', TRUE) : FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->_mysqli;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -147,6 +257,7 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
if ($this->conn_id->select_db($database))
|
if ($this->conn_id->select_db($database))
|
||||||
{
|
{
|
||||||
$this->database = $database;
|
$this->database = $database;
|
||||||
|
$this->data_cache = array();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,10 +290,6 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
{
|
{
|
||||||
return $this->data_cache['version'];
|
return $this->data_cache['version'];
|
||||||
}
|
}
|
||||||
elseif ( ! $this->conn_id)
|
|
||||||
{
|
|
||||||
$this->initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->data_cache['version'] = $this->conn_id->server_info;
|
return $this->data_cache['version'] = $this->conn_id->server_info;
|
||||||
}
|
}
|
||||||
@ -227,22 +334,10 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* Begin Transaction
|
* Begin Transaction
|
||||||
*
|
*
|
||||||
* @param bool $test_mode
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_begin($test_mode = FALSE)
|
protected function _trans_begin()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset the transaction failure flag.
|
|
||||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
|
||||||
// even if the queries produce a successful result.
|
|
||||||
$this->_trans_failure = ($test_mode === TRUE);
|
|
||||||
|
|
||||||
$this->conn_id->autocommit(FALSE);
|
$this->conn_id->autocommit(FALSE);
|
||||||
return is_php('5.5')
|
return is_php('5.5')
|
||||||
? $this->conn_id->begin_transaction()
|
? $this->conn_id->begin_transaction()
|
||||||
@ -256,14 +351,8 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_commit()
|
protected function _trans_commit()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->conn_id->commit())
|
if ($this->conn_id->commit())
|
||||||
{
|
{
|
||||||
$this->conn_id->autocommit(TRUE);
|
$this->conn_id->autocommit(TRUE);
|
||||||
@ -280,14 +369,8 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_rollback()
|
protected function _trans_rollback()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->conn_id->rollback())
|
if ($this->conn_id->rollback())
|
||||||
{
|
{
|
||||||
$this->conn_id->autocommit(TRUE);
|
$this->conn_id->autocommit(TRUE);
|
||||||
@ -300,16 +383,14 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform-dependant string escape
|
* Platform-dependent string escape
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function _escape_str($str)
|
protected function _escape_str($str)
|
||||||
{
|
{
|
||||||
return is_object($this->conn_id)
|
return $this->conn_id->real_escape_string($str);
|
||||||
? $this->conn_id->real_escape_string($str)
|
|
||||||
: addslashes($str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -381,13 +462,8 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
* @param string $table
|
* @param string $table
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function field_data($table = '')
|
public function field_data($table)
|
||||||
{
|
{
|
||||||
if ($table === '')
|
|
||||||
{
|
|
||||||
return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
|
if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -418,17 +494,17 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
* Error
|
* Error
|
||||||
*
|
*
|
||||||
* Returns an array containing code and message of the last
|
* Returns an array containing code and message of the last
|
||||||
* database error that has occured.
|
* database error that has occurred.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function error()
|
public function error()
|
||||||
{
|
{
|
||||||
if ( ! empty($this->conn_id->connect_errno))
|
if ( ! empty($this->_mysqli->connect_errno))
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'code' => $this->conn_id->connect_errno,
|
'code' => $this->_mysqli->connect_errno,
|
||||||
'message' => is_php('5.2.9') ? $this->conn_id->connect_error : mysqli_connect_error()
|
'message' => $this->_mysqli->connect_error
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,6 +544,3 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file mysqli_driver.php */
|
|
||||||
/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */
|
|
53
system/database/drivers/mysqli/mysqli_forge.php
Executable file → Normal file
53
system/database/drivers/mysqli/mysqli_forge.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.3.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -29,9 +40,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
/**
|
/**
|
||||||
* MySQLi Forge Class
|
* MySQLi Forge Class
|
||||||
*
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_mysqli_forge extends CI_DB_forge {
|
class CI_DB_mysqli_forge extends CI_DB_forge {
|
||||||
|
|
||||||
@ -77,7 +90,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
|
|||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $_null = 'NULL';
|
protected $_null = 'NULL';
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
@ -182,6 +195,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
|
|||||||
.$field['default']
|
.$field['default']
|
||||||
.$field['auto_increment']
|
.$field['auto_increment']
|
||||||
.$field['unique']
|
.$field['unique']
|
||||||
|
.(empty($field['comment']) ? '' : ' COMMENT '.$field['comment'])
|
||||||
.$extra_clause;
|
.$extra_clause;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,6 +242,3 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file mysqli_forge.php */
|
|
||||||
/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */
|
|
101
system/database/drivers/mysqli/mysqli_result.php
Executable file → Normal file
101
system/database/drivers/mysqli/mysqli_result.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.3.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,10 +42,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* This class extends the parent result class: CI_DB_result
|
* This class extends the parent result class: CI_DB_result
|
||||||
*
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
* @since 1.3
|
|
||||||
*/
|
*/
|
||||||
class CI_DB_mysqli_result extends CI_DB_result {
|
class CI_DB_mysqli_result extends CI_DB_result {
|
||||||
|
|
||||||
@ -100,9 +112,9 @@ class CI_DB_mysqli_result extends CI_DB_result {
|
|||||||
{
|
{
|
||||||
$retval[$i] = new stdClass();
|
$retval[$i] = new stdClass();
|
||||||
$retval[$i]->name = $field_data[$i]->name;
|
$retval[$i]->name = $field_data[$i]->name;
|
||||||
$retval[$i]->type = $field_data[$i]->type;
|
$retval[$i]->type = static::_get_field_type($field_data[$i]->type);
|
||||||
$retval[$i]->max_length = $field_data[$i]->max_length;
|
$retval[$i]->max_length = $field_data[$i]->max_length;
|
||||||
$retval[$i]->primary_key = (int) ($field_data[$i]->flags & 2);
|
$retval[$i]->primary_key = (int) ($field_data[$i]->flags & MYSQLI_PRI_KEY_FLAG);
|
||||||
$retval[$i]->default = $field_data[$i]->def;
|
$retval[$i]->default = $field_data[$i]->def;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,6 +123,52 @@ class CI_DB_mysqli_result extends CI_DB_result {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get field type
|
||||||
|
*
|
||||||
|
* Extracts field type info from the bitflags returned by
|
||||||
|
* mysqli_result::fetch_fields()
|
||||||
|
*
|
||||||
|
* @used-by CI_DB_mysqli_result::field_data()
|
||||||
|
* @param int $type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
private static function _get_field_type($type)
|
||||||
|
{
|
||||||
|
static $map;
|
||||||
|
isset($map) OR $map = array(
|
||||||
|
MYSQLI_TYPE_DECIMAL => 'decimal',
|
||||||
|
MYSQLI_TYPE_BIT => 'bit',
|
||||||
|
MYSQLI_TYPE_TINY => 'tinyint',
|
||||||
|
MYSQLI_TYPE_SHORT => 'smallint',
|
||||||
|
MYSQLI_TYPE_INT24 => 'mediumint',
|
||||||
|
MYSQLI_TYPE_LONG => 'int',
|
||||||
|
MYSQLI_TYPE_LONGLONG => 'bigint',
|
||||||
|
MYSQLI_TYPE_FLOAT => 'float',
|
||||||
|
MYSQLI_TYPE_DOUBLE => 'double',
|
||||||
|
MYSQLI_TYPE_TIMESTAMP => 'timestamp',
|
||||||
|
MYSQLI_TYPE_DATE => 'date',
|
||||||
|
MYSQLI_TYPE_TIME => 'time',
|
||||||
|
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',
|
||||||
|
MYSQLI_TYPE_MEDIUM_BLOB => 'mediumblob',
|
||||||
|
MYSQLI_TYPE_BLOB => 'blob',
|
||||||
|
MYSQLI_TYPE_LONG_BLOB => 'longblob',
|
||||||
|
MYSQLI_TYPE_STRING => 'char',
|
||||||
|
MYSQLI_TYPE_VAR_STRING => 'varchar',
|
||||||
|
MYSQLI_TYPE_GEOMETRY => 'geometry'
|
||||||
|
);
|
||||||
|
|
||||||
|
return isset($map[$type]) ? $map[$type] : $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free the result
|
* Free the result
|
||||||
*
|
*
|
||||||
@ -172,6 +230,3 @@ class CI_DB_mysqli_result extends CI_DB_result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file mysqli_result.php */
|
|
||||||
/* Location: ./system/database/drivers/mysqli/mysqli_result.php */
|
|
54
system/database/drivers/mysqli/mysqli_utility.php
Executable file → Normal file
54
system/database/drivers/mysqli/mysqli_utility.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.3.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -29,9 +40,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
/**
|
/**
|
||||||
* MySQLi Utility Class
|
* MySQLi Utility Class
|
||||||
*
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_mysqli_utility extends CI_DB_utility {
|
class CI_DB_mysqli_utility extends CI_DB_utility {
|
||||||
|
|
||||||
@ -142,9 +155,7 @@ class CI_DB_mysqli_utility extends CI_DB_utility {
|
|||||||
while ($field = $query->result_id->fetch_field())
|
while ($field = $query->result_id->fetch_field())
|
||||||
{
|
{
|
||||||
// Most versions of MySQL store timestamp as a string
|
// Most versions of MySQL store timestamp as a string
|
||||||
$is_int[$i] = in_array(strtolower($field->type),
|
$is_int[$i] = in_array($field->type, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_INT24, MYSQLI_TYPE_LONG), TRUE);
|
||||||
array('tinyint', 'smallint', 'mediumint', 'int', 'bigint'), //, 'timestamp'),
|
|
||||||
TRUE);
|
|
||||||
|
|
||||||
// Create a string of field names
|
// Create a string of field names
|
||||||
$field_str .= $this->db->escape_identifiers($field->name).', ';
|
$field_str .= $this->db->escape_identifiers($field->name).', ';
|
||||||
@ -198,6 +209,3 @@ class CI_DB_mysqli_utility extends CI_DB_utility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file mysqli_utility.php */
|
|
||||||
/* Location: ./system/database/drivers/mysqli/mysqli_utility.php */
|
|
3
system/database/drivers/oci8/index.html
Executable file → Normal file
3
system/database/drivers/oci8/index.html
Executable file → Normal file
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>403 Forbidden</title>
|
<title>403 Forbidden</title>
|
||||||
@ -7,4 +8,4 @@
|
|||||||
<p>Directory access is forbidden.</p>
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
213
system/database/drivers/oci8/oci8_driver.php
Executable file → Normal file
213
system/database/drivers/oci8/oci8_driver.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.4.1
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -37,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,10 +97,18 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public $limit_used;
|
public $limit_used = FALSE;
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset $stmt_id flag
|
||||||
|
*
|
||||||
|
* Used by stored_procedure() to prevent _execute() from
|
||||||
|
* re-setting the statement ID.
|
||||||
|
*/
|
||||||
|
protected $_reset_stmt_id = TRUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of reserved identifiers
|
* List of reserved identifiers
|
||||||
*
|
*
|
||||||
@ -232,17 +251,17 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
{
|
{
|
||||||
return $this->data_cache['version'];
|
return $this->data_cache['version'];
|
||||||
}
|
}
|
||||||
elseif ( ! $this->conn_id)
|
|
||||||
{
|
|
||||||
$this->initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! $this->conn_id OR ($version = oci_server_version($this->conn_id)) === FALSE)
|
if ( ! $this->conn_id OR ($version_string = oci_server_version($this->conn_id)) === FALSE)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
elseif (preg_match('#Release\s(\d+(?:\.\d+)+)#', $version_string, $match))
|
||||||
|
{
|
||||||
|
return $this->data_cache['version'] = $match[1];
|
||||||
|
}
|
||||||
|
|
||||||
return $this->data_cache['version'] = $version;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -258,26 +277,13 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
/* Oracle must parse the query before it is run. All of the actions with
|
/* 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().
|
* the query are based on the statement id returned by oci_parse().
|
||||||
*/
|
*/
|
||||||
$this->stmt_id = FALSE;
|
if ($this->_reset_stmt_id === TRUE)
|
||||||
$this->_set_stmt_id($sql);
|
|
||||||
oci_set_prefetch($this->stmt_id, 1000);
|
|
||||||
return oci_execute($this->stmt_id, $this->commit_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a statement ID
|
|
||||||
*
|
|
||||||
* @param string $sql an SQL query
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function _set_stmt_id($sql)
|
|
||||||
{
|
|
||||||
if ( ! is_resource($this->stmt_id))
|
|
||||||
{
|
{
|
||||||
$this->stmt_id = oci_parse($this->conn_id, $sql);
|
$this->stmt_id = oci_parse($this->conn_id, $sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oci_set_prefetch($this->stmt_id, 1000);
|
||||||
|
return oci_execute($this->stmt_id, $this->commit_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -304,22 +310,22 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* params array keys
|
* params array keys
|
||||||
*
|
*
|
||||||
* KEY OPTIONAL NOTES
|
* KEY OPTIONAL NOTES
|
||||||
* name no the name of the parameter should be in :<param_name> format
|
* 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,
|
* value no the value of the parameter. If this is an OUT or IN OUT parameter,
|
||||||
* this should be a reference to a variable
|
* this should be a reference to a variable
|
||||||
* type yes the type of the parameter
|
* type yes the type of the parameter
|
||||||
* length yes the max size of the parameter
|
* length yes the max size of the parameter
|
||||||
*/
|
*/
|
||||||
public function stored_procedure($package, $procedure, $params)
|
public function stored_procedure($package, $procedure, array $params)
|
||||||
{
|
{
|
||||||
if ($package === '' OR $procedure === '' OR ! is_array($params))
|
if ($package === '' OR $procedure === '')
|
||||||
{
|
{
|
||||||
log_message('error', 'Invalid query: '.$package.'.'.$procedure);
|
log_message('error', 'Invalid query: '.$package.'.'.$procedure);
|
||||||
return ($this->db_debug) ? $this->display_error('db_invalid_query') : FALSE;
|
return ($this->db_debug) ? $this->display_error('db_invalid_query') : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// build the query string
|
// Build the query string
|
||||||
$sql = 'BEGIN '.$package.'.'.$procedure.'(';
|
$sql = 'BEGIN '.$package.'.'.$procedure.'(';
|
||||||
|
|
||||||
$have_cursor = FALSE;
|
$have_cursor = FALSE;
|
||||||
@ -334,10 +340,12 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
$sql = trim($sql, ',').'); END;';
|
$sql = trim($sql, ',').'); END;';
|
||||||
|
|
||||||
$this->stmt_id = FALSE;
|
$this->_reset_stmt_id = FALSE;
|
||||||
$this->_set_stmt_id($sql);
|
$this->stmt_id = oci_parse($this->conn_id, $sql);
|
||||||
$this->_bind_params($params);
|
$this->_bind_params($params);
|
||||||
return $this->query($sql, FALSE, $have_cursor);
|
$result = $this->query($sql, FALSE, $have_cursor);
|
||||||
|
$this->_reset_stmt_id = TRUE;
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -374,28 +382,11 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* Begin Transaction
|
* Begin Transaction
|
||||||
*
|
*
|
||||||
* @param bool $test_mode
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_begin($test_mode = FALSE)
|
protected function _trans_begin()
|
||||||
{
|
{
|
||||||
if ( ! $this->trans_enabled)
|
$this->commit_mode = OCI_NO_AUTO_COMMIT;
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ($this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset the transaction failure flag.
|
|
||||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
|
||||||
// even if the queries produce a successful result.
|
|
||||||
$this->_trans_failure = ($test_mode === TRUE);
|
|
||||||
|
|
||||||
$this->commit_mode = is_php('5.3.2') ? OCI_NO_AUTO_COMMIT : OCI_DEFAULT;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,20 +397,10 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_commit()
|
protected function _trans_commit()
|
||||||
{
|
{
|
||||||
if ( ! $this->trans_enabled)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ($this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->commit_mode = OCI_COMMIT_ON_SUCCESS;
|
$this->commit_mode = OCI_COMMIT_ON_SUCCESS;
|
||||||
|
|
||||||
return oci_commit($this->conn_id);
|
return oci_commit($this->conn_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,14 +411,8 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_rollback()
|
protected function _trans_rollback()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->commit_mode = OCI_COMMIT_ON_SUCCESS;
|
$this->commit_mode = OCI_COMMIT_ON_SUCCESS;
|
||||||
return oci_rollback($this->conn_id);
|
return oci_rollback($this->conn_id);
|
||||||
}
|
}
|
||||||
@ -524,13 +499,9 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @param string $table
|
* @param string $table
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function field_data($table = '')
|
public function field_data($table)
|
||||||
{
|
{
|
||||||
if ($table === '')
|
if (strpos($table, '.') !== FALSE)
|
||||||
{
|
|
||||||
return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
|
|
||||||
}
|
|
||||||
elseif (strpos($table, '.') !== FALSE)
|
|
||||||
{
|
{
|
||||||
sscanf($table, '%[^.].%s', $owner, $table);
|
sscanf($table, '%[^.].%s', $owner, $table);
|
||||||
}
|
}
|
||||||
@ -570,7 +541,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
{
|
{
|
||||||
$default = '';
|
$default = '';
|
||||||
}
|
}
|
||||||
$retval[$i]->default = $query[$i]->COLUMN_DEFAULT;
|
$retval[$i]->default = $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $retval;
|
return $retval;
|
||||||
@ -582,29 +553,35 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* Error
|
* Error
|
||||||
*
|
*
|
||||||
* Returns an array containing code and message of the last
|
* Returns an array containing code and message of the last
|
||||||
* database error that has occured.
|
* database error that has occurred.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function error()
|
public function error()
|
||||||
{
|
{
|
||||||
/* oci_error() returns an array that already contains the
|
// oci_error() returns an array that already contains
|
||||||
* 'code' and 'message' keys, so we can just return it.
|
// 'code' and 'message' keys, but it can return false
|
||||||
*/
|
// if there was no error ....
|
||||||
if (is_resource($this->curs_id))
|
if (is_resource($this->curs_id))
|
||||||
{
|
{
|
||||||
return oci_error($this->curs_id);
|
$error = oci_error($this->curs_id);
|
||||||
}
|
}
|
||||||
elseif (is_resource($this->stmt_id))
|
elseif (is_resource($this->stmt_id))
|
||||||
{
|
{
|
||||||
return oci_error($this->stmt_id);
|
$error = oci_error($this->stmt_id);
|
||||||
}
|
}
|
||||||
elseif (is_resource($this->conn_id))
|
elseif (is_resource($this->conn_id))
|
||||||
{
|
{
|
||||||
return oci_error($this->conn_id);
|
$error = oci_error($this->conn_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error = oci_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
return oci_error();
|
return is_array($error)
|
||||||
|
? $error
|
||||||
|
: array('code' => '', 'message' => '');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -683,6 +660,14 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
protected function _limit($sql)
|
protected function _limit($sql)
|
||||||
{
|
{
|
||||||
|
if (version_compare($this->version(), '12.1', '>='))
|
||||||
|
{
|
||||||
|
// OFFSET-FETCH can be used only with the ORDER BY clause
|
||||||
|
empty($this->qb_orderby) && $sql .= ' ORDER BY 1';
|
||||||
|
|
||||||
|
return $sql.' OFFSET '.(int) $this->qb_offset.' ROWS FETCH NEXT '.$this->qb_limit.' ROWS ONLY';
|
||||||
|
}
|
||||||
|
|
||||||
$this->limit_used = TRUE;
|
$this->limit_used = TRUE;
|
||||||
return 'SELECT * FROM (SELECT inner_query.*, rownum rnum FROM ('.$sql.') inner_query WHERE rownum < '.($this->qb_offset + $this->qb_limit + 1).')'
|
return 'SELECT * FROM (SELECT inner_query.*, rownum rnum FROM ('.$sql.') inner_query WHERE rownum < '.($this->qb_offset + $this->qb_limit + 1).')'
|
||||||
.($this->qb_offset ? ' WHERE rnum >= '.($this->qb_offset + 1) : '');
|
.($this->qb_offset ? ' WHERE rnum >= '.($this->qb_offset + 1) : '');
|
||||||
@ -700,7 +685,17 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
oci_close($this->conn_id);
|
oci_close($this->conn_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/* End of file oci8_driver.php */
|
/**
|
||||||
/* Location: ./system/database/drivers/oci8/oci8_driver.php */
|
* We need to reset our $limit_used hack flag, so it doesn't propagate
|
||||||
|
* to subsequent queries.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function _reset_select()
|
||||||
|
{
|
||||||
|
$this->limit_used = FALSE;
|
||||||
|
parent::_reset_select();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
98
system/database/drivers/oci8/oci8_forge.php
Executable file → Normal file
98
system/database/drivers/oci8/oci8_forge.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.4.1
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_oci8_forge extends CI_DB_forge {
|
class CI_DB_oci8_forge extends CI_DB_forge {
|
||||||
|
|
||||||
@ -42,6 +53,13 @@ class CI_DB_oci8_forge extends CI_DB_forge {
|
|||||||
*/
|
*/
|
||||||
protected $_create_database = FALSE;
|
protected $_create_database = FALSE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CREATE TABLE IF statement
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $_create_table_if = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DROP DATABASE statement
|
* DROP DATABASE statement
|
||||||
*
|
*
|
||||||
@ -95,11 +113,21 @@ class CI_DB_oci8_forge extends CI_DB_forge {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$field[$i]['_literal'] = "\n\t".$this->_process_column($field[$i]);
|
$field[$i]['_literal'] = "\n\t".$this->_process_column($field[$i]);
|
||||||
|
|
||||||
|
if ( ! empty($field[$i]['comment']))
|
||||||
|
{
|
||||||
|
$sqls[] = 'COMMENT ON COLUMN '
|
||||||
|
.$this->db->escape_identifiers($table).'.'.$this->db->escape_identifiers($field[$i]['name'])
|
||||||
|
.' IS '.$field[$i]['comment'];
|
||||||
|
}
|
||||||
|
|
||||||
if ($alter_type === 'MODIFY' && ! empty($field[$i]['new_name']))
|
if ($alter_type === 'MODIFY' && ! empty($field[$i]['new_name']))
|
||||||
{
|
{
|
||||||
$sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
|
$sqls[] = $sql.' RENAME COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
|
||||||
.' '.$this->db->escape_identifiers($field[$i]['new_name']);
|
.' TO '.$this->db->escape_identifiers($field[$i]['new_name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$field[$i] = "\n\t".$field[$i]['_literal'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +138,7 @@ class CI_DB_oci8_forge extends CI_DB_forge {
|
|||||||
|
|
||||||
// RENAME COLUMN must be executed after MODIFY
|
// RENAME COLUMN must be executed after MODIFY
|
||||||
array_unshift($sqls, $sql);
|
array_unshift($sqls, $sql);
|
||||||
return $sql;
|
return $sqls;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -127,7 +155,33 @@ class CI_DB_oci8_forge extends CI_DB_forge {
|
|||||||
// Not supported - sequences and triggers must be used instead
|
// Not supported - sequences and triggers must be used instead
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/* End of file oci8_forge.php */
|
/**
|
||||||
/* Location: ./system/database/drivers/oci8/oci8_forge.php */
|
* Field attribute TYPE
|
||||||
|
*
|
||||||
|
* Performs a data type mapping between different databases.
|
||||||
|
*
|
||||||
|
* @param array &$attributes
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function _attr_type(&$attributes)
|
||||||
|
{
|
||||||
|
switch (strtoupper($attributes['TYPE']))
|
||||||
|
{
|
||||||
|
case 'TINYINT':
|
||||||
|
$attributes['TYPE'] = 'NUMBER';
|
||||||
|
return;
|
||||||
|
case 'MEDIUMINT':
|
||||||
|
$attributes['TYPE'] = 'NUMBER';
|
||||||
|
return;
|
||||||
|
case 'INT':
|
||||||
|
$attributes['TYPE'] = 'NUMBER';
|
||||||
|
return;
|
||||||
|
case 'BIGINT':
|
||||||
|
$attributes['TYPE'] = 'NUMBER';
|
||||||
|
return;
|
||||||
|
default: return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
49
system/database/drivers/oci8/oci8_result.php
Executable file → Normal file
49
system/database/drivers/oci8/oci8_result.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.4.1
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -33,8 +44,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
* @since 1.4.1
|
|
||||||
*/
|
*/
|
||||||
class CI_DB_oci8_result extends CI_DB_result {
|
class CI_DB_oci8_result extends CI_DB_result {
|
||||||
|
|
||||||
@ -217,6 +227,3 @@ class CI_DB_oci8_result extends CI_DB_result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file oci8_result.php */
|
|
||||||
/* Location: ./system/database/drivers/oci8/oci8_result.php */
|
|
48
system/database/drivers/oci8/oci8_utility.php
Executable file → Normal file
48
system/database/drivers/oci8/oci8_utility.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.4.1
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_oci8_utility extends CI_DB_utility {
|
class CI_DB_oci8_utility extends CI_DB_utility {
|
||||||
|
|
||||||
@ -55,6 +66,3 @@ class CI_DB_oci8_utility extends CI_DB_utility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file oci8_utility.php */
|
|
||||||
/* Location: ./system/database/drivers/oci8/oci8_utility.php */
|
|
3
system/database/drivers/odbc/index.html
Executable file → Normal file
3
system/database/drivers/odbc/index.html
Executable file → Normal file
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>403 Forbidden</title>
|
<title>403 Forbidden</title>
|
||||||
@ -7,4 +8,4 @@
|
|||||||
<p>Directory access is forbidden.</p>
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
267
system/database/drivers/odbc/odbc_driver.php
Executable file → Normal file
267
system/database/drivers/odbc/odbc_driver.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.3.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -37,9 +48,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_odbc_driver extends CI_DB {
|
class CI_DB_odbc_driver extends CI_DB_driver {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database driver
|
* Database driver
|
||||||
@ -82,6 +93,22 @@ class CI_DB_odbc_driver extends CI_DB {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ODBC result ID resource returned from odbc_prepare()
|
||||||
|
*
|
||||||
|
* @var resource
|
||||||
|
*/
|
||||||
|
private $odbc_result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Values to use with odbc_execute() for prepared statements
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private $binds = array();
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
@ -116,6 +143,74 @@ class CI_DB_odbc_driver extends CI_DB {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile Bindings
|
||||||
|
*
|
||||||
|
* @param string $sql SQL statement
|
||||||
|
* @param array $binds An array of values to bind
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function compile_binds($sql, $binds)
|
||||||
|
{
|
||||||
|
if (empty($binds) OR empty($this->bind_marker) OR strpos($sql, $this->bind_marker) === FALSE)
|
||||||
|
{
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
elseif ( ! is_array($binds))
|
||||||
|
{
|
||||||
|
$binds = array($binds);
|
||||||
|
$bind_count = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Make sure we're using numeric keys
|
||||||
|
$binds = array_values($binds);
|
||||||
|
$bind_count = count($binds);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We'll need the marker length later
|
||||||
|
$ml = strlen($this->bind_marker);
|
||||||
|
|
||||||
|
// Make sure not to replace a chunk inside a string that happens to match the bind marker
|
||||||
|
if ($c = preg_match_all("/'[^']*'|\"[^\"]*\"/i", $sql, $matches))
|
||||||
|
{
|
||||||
|
$c = preg_match_all('/'.preg_quote($this->bind_marker, '/').'/i',
|
||||||
|
str_replace($matches[0],
|
||||||
|
str_replace($this->bind_marker, str_repeat(' ', $ml), $matches[0]),
|
||||||
|
$sql, $c),
|
||||||
|
$matches, PREG_OFFSET_CAPTURE);
|
||||||
|
|
||||||
|
// Bind values' count must match the count of markers in the query
|
||||||
|
if ($bind_count !== $c)
|
||||||
|
{
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif (($c = preg_match_all('/'.preg_quote($this->bind_marker, '/').'/i', $sql, $matches, PREG_OFFSET_CAPTURE)) !== $bind_count)
|
||||||
|
{
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->bind_marker !== '?')
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
$c--;
|
||||||
|
$sql = substr_replace($sql, '?', $matches[0][$c][1], $ml);
|
||||||
|
}
|
||||||
|
while ($c !== 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FALSE !== ($this->odbc_result = odbc_prepare($this->conn_id, $sql)))
|
||||||
|
{
|
||||||
|
$this->binds = array_values($binds);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the query
|
* Execute the query
|
||||||
*
|
*
|
||||||
@ -124,7 +219,25 @@ class CI_DB_odbc_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
protected function _execute($sql)
|
protected function _execute($sql)
|
||||||
{
|
{
|
||||||
return odbc_exec($this->conn_id, $sql);
|
if ( ! isset($this->odbc_result))
|
||||||
|
{
|
||||||
|
return odbc_exec($this->conn_id, $sql);
|
||||||
|
}
|
||||||
|
elseif ($this->odbc_result === FALSE)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (TRUE === ($success = odbc_execute($this->odbc_result, $this->binds)))
|
||||||
|
{
|
||||||
|
// For queries that return result sets, return the result_id resource on success
|
||||||
|
$this->is_write_type($sql) OR $success = $this->odbc_result;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->odbc_result = NULL;
|
||||||
|
$this->binds = array();
|
||||||
|
|
||||||
|
return $success;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -132,22 +245,10 @@ class CI_DB_odbc_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* Begin Transaction
|
* Begin Transaction
|
||||||
*
|
*
|
||||||
* @param bool $test_mode
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_begin($test_mode = FALSE)
|
protected function _trans_begin()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset the transaction failure flag.
|
|
||||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
|
||||||
// even if the queries produce a successful result.
|
|
||||||
$this->_trans_failure = ($test_mode === TRUE);
|
|
||||||
|
|
||||||
return odbc_autocommit($this->conn_id, FALSE);
|
return odbc_autocommit($this->conn_id, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,17 +259,15 @@ class CI_DB_odbc_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_commit()
|
protected function _trans_commit()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
if (odbc_commit($this->conn_id))
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
{
|
||||||
|
odbc_autocommit($this->conn_id, TRUE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = odbc_commit($this->conn_id);
|
return FALSE;
|
||||||
odbc_autocommit($this->conn_id, TRUE);
|
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -178,30 +277,46 @@ class CI_DB_odbc_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_rollback()
|
protected function _trans_rollback()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
if (odbc_rollback($this->conn_id))
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
{
|
||||||
|
odbc_autocommit($this->conn_id, TRUE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = odbc_rollback($this->conn_id);
|
return FALSE;
|
||||||
odbc_autocommit($this->conn_id, TRUE);
|
|
||||||
return $ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform-dependant string escape
|
* Determines if a query is a "write" type.
|
||||||
|
*
|
||||||
|
* @param string An SQL query string
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function is_write_type($sql)
|
||||||
|
{
|
||||||
|
if (preg_match('#^(INSERT|UPDATE).*RETURNING\s.+(\,\s?.+)*$#is', $sql))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::is_write_type($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Platform-dependent string escape
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function _escape_str($str)
|
protected function _escape_str($str)
|
||||||
{
|
{
|
||||||
return remove_invisible_characters($str);
|
$this->display_error('db_unsupported_feature');
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -225,7 +340,7 @@ class CI_DB_odbc_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
public function insert_id()
|
public function insert_id()
|
||||||
{
|
{
|
||||||
return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
|
return ($this->db_debug) ? $this->display_error('db_unsupported_feature') : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@ -287,7 +402,7 @@ class CI_DB_odbc_driver extends CI_DB {
|
|||||||
* Error
|
* Error
|
||||||
*
|
*
|
||||||
* Returns an array containing code and message of the last
|
* Returns an array containing code and message of the last
|
||||||
* database error that has occured.
|
* database error that has occurred.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -298,58 +413,6 @@ class CI_DB_odbc_driver extends CI_DB {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* Update statement
|
|
||||||
*
|
|
||||||
* Generates a platform-specific update string from the supplied data
|
|
||||||
*
|
|
||||||
* @param string $table
|
|
||||||
* @param array $values
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function _update($table, $values)
|
|
||||||
{
|
|
||||||
$this->qb_limit = FALSE;
|
|
||||||
$this->qb_orderby = array();
|
|
||||||
return parent::_update($table, $values);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Truncate statement
|
|
||||||
*
|
|
||||||
* Generates a platform-specific truncate string from the supplied data
|
|
||||||
*
|
|
||||||
* If the database does not support the TRUNCATE statement,
|
|
||||||
* then this method maps to 'DELETE FROM table'
|
|
||||||
*
|
|
||||||
* @param string $table
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function _truncate($table)
|
|
||||||
{
|
|
||||||
return 'DELETE FROM '.$table;
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete statement
|
|
||||||
*
|
|
||||||
* Generates a platform-specific delete string from the supplied data
|
|
||||||
*
|
|
||||||
* @param string $table
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function _delete($table)
|
|
||||||
{
|
|
||||||
$this->qb_limit = FALSE;
|
|
||||||
return parent::_delete($table);
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close DB Connection
|
* Close DB Connection
|
||||||
*
|
*
|
||||||
@ -359,8 +422,4 @@ class CI_DB_odbc_driver extends CI_DB {
|
|||||||
{
|
{
|
||||||
odbc_close($this->conn_id);
|
odbc_close($this->conn_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file odbc_driver.php */
|
|
||||||
/* Location: ./system/database/drivers/odbc/odbc_driver.php */
|
|
50
system/database/drivers/odbc/odbc_forge.php
Executable file → Normal file
50
system/database/drivers/odbc/odbc_forge.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.3.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -29,9 +40,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
/**
|
/**
|
||||||
* ODBC Forge Class
|
* ODBC Forge Class
|
||||||
*
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/database/
|
* @link https://codeigniter.com/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_odbc_forge extends CI_DB_forge {
|
class CI_DB_odbc_forge extends CI_DB_forge {
|
||||||
|
|
||||||
@ -71,6 +84,3 @@ class CI_DB_odbc_forge extends CI_DB_forge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file odbc_forge.php */
|
|
||||||
/* Location: ./system/database/drivers/odbc/odbc_forge.php */
|
|
51
system/database/drivers/odbc/odbc_result.php
Executable file → Normal file
51
system/database/drivers/odbc/odbc_result.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.3.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,10 +42,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* This class extends the parent result class: CI_DB_result
|
* This class extends the parent result class: CI_DB_result
|
||||||
*
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
* @since 1.3
|
|
||||||
*/
|
*/
|
||||||
class CI_DB_odbc_result extends CI_DB_result {
|
class CI_DB_odbc_result extends CI_DB_result {
|
||||||
|
|
||||||
@ -254,6 +266,3 @@ if ( ! function_exists('odbc_fetch_object'))
|
|||||||
return $rs_object;
|
return $rs_object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file odbc_result.php */
|
|
||||||
/* Location: ./system/database/drivers/odbc/odbc_result.php */
|
|
50
system/database/drivers/odbc/odbc_utility.php
Executable file → Normal file
50
system/database/drivers/odbc/odbc_utility.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 1.3.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -29,9 +40,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
/**
|
/**
|
||||||
* ODBC Utility Class
|
* ODBC Utility Class
|
||||||
*
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/database/
|
* @link https://codeigniter.com/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_odbc_utility extends CI_DB_utility {
|
class CI_DB_odbc_utility extends CI_DB_utility {
|
||||||
|
|
||||||
@ -48,6 +61,3 @@ class CI_DB_odbc_utility extends CI_DB_utility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file odbc_utility.php */
|
|
||||||
/* Location: ./system/database/drivers/odbc/odbc_utility.php */
|
|
3
system/database/drivers/pdo/index.html
Executable file → Normal file
3
system/database/drivers/pdo/index.html
Executable file → Normal file
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>403 Forbidden</title>
|
<title>403 Forbidden</title>
|
||||||
@ -7,4 +8,4 @@
|
|||||||
<p>Directory access is forbidden.</p>
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
137
system/database/drivers/pdo/pdo_driver.php
Executable file → Normal file
137
system/database/drivers/pdo/pdo_driver.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 2.1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 2.1.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -37,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_pdo_driver extends CI_DB {
|
class CI_DB_pdo_driver extends CI_DB {
|
||||||
|
|
||||||
@ -115,7 +126,10 @@ class CI_DB_pdo_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
public function db_connect($persistent = FALSE)
|
public function db_connect($persistent = FALSE)
|
||||||
{
|
{
|
||||||
$this->options[PDO::ATTR_PERSISTENT] = $persistent;
|
if ($persistent === TRUE)
|
||||||
|
{
|
||||||
|
$this->options[PDO::ATTR_PERSISTENT] = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -145,10 +159,6 @@ class CI_DB_pdo_driver extends CI_DB {
|
|||||||
{
|
{
|
||||||
return $this->data_cache['version'];
|
return $this->data_cache['version'];
|
||||||
}
|
}
|
||||||
elseif ( ! $this->conn_id)
|
|
||||||
{
|
|
||||||
$this->initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not all subdrivers support the getAttribute() method
|
// Not all subdrivers support the getAttribute() method
|
||||||
try
|
try
|
||||||
@ -179,22 +189,10 @@ class CI_DB_pdo_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* Begin Transaction
|
* Begin Transaction
|
||||||
*
|
*
|
||||||
* @param bool $test_mode
|
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_begin($test_mode = FALSE)
|
protected function _trans_begin()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset the transaction failure flag.
|
|
||||||
// If the $test_mode flag is set to TRUE transactions will be rolled back
|
|
||||||
// even if the queries produce a successful result.
|
|
||||||
$this->_trans_failure = ($test_mode === TRUE);
|
|
||||||
|
|
||||||
return $this->conn_id->beginTransaction();
|
return $this->conn_id->beginTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,14 +203,8 @@ class CI_DB_pdo_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_commit()
|
protected function _trans_commit()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->conn_id->commit();
|
return $this->conn_id->commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,21 +215,15 @@ class CI_DB_pdo_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function trans_rollback()
|
protected function _trans_rollback()
|
||||||
{
|
{
|
||||||
// When transactions are nested we only begin/commit/rollback the outermost ones
|
|
||||||
if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->conn_id->rollBack();
|
return $this->conn_id->rollBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform-dependant string escape
|
* Platform-dependent string escape
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
@ -299,7 +285,7 @@ class CI_DB_pdo_driver extends CI_DB {
|
|||||||
* Error
|
* Error
|
||||||
*
|
*
|
||||||
* Returns an array containing code and message of the last
|
* Returns an array containing code and message of the last
|
||||||
* database error that has occured.
|
* database error that has occurred.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -324,52 +310,6 @@ class CI_DB_pdo_driver extends CI_DB {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* Update_Batch statement
|
|
||||||
*
|
|
||||||
* Generates a platform-specific batch update string from the supplied data
|
|
||||||
*
|
|
||||||
* @param string $table Table name
|
|
||||||
* @param array $values Update data
|
|
||||||
* @param string $index WHERE key
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function _update_batch($table, $values, $index)
|
|
||||||
{
|
|
||||||
$ids = array();
|
|
||||||
foreach ($values as $key => $val)
|
|
||||||
{
|
|
||||||
$ids[] = $val[$index];
|
|
||||||
|
|
||||||
foreach (array_keys($val) as $field)
|
|
||||||
{
|
|
||||||
if ($field !== $index)
|
|
||||||
{
|
|
||||||
$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$cases = '';
|
|
||||||
foreach ($final as $k => $v)
|
|
||||||
{
|
|
||||||
$cases .= $k.' = CASE '."\n";
|
|
||||||
|
|
||||||
foreach ($v as $row)
|
|
||||||
{
|
|
||||||
$cases .= $row."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$cases .= 'ELSE '.$k.' END, ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE);
|
|
||||||
|
|
||||||
return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where');
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Truncate statement
|
* Truncate statement
|
||||||
*
|
*
|
||||||
@ -387,6 +327,3 @@ class CI_DB_pdo_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file pdo_driver.php */
|
|
||||||
/* Location: ./system/database/drivers/pdo/pdo_driver.php */
|
|
50
system/database/drivers/pdo/pdo_forge.php
Executable file → Normal file
50
system/database/drivers/pdo/pdo_forge.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 2.1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 2.1.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -29,9 +40,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
/**
|
/**
|
||||||
* PDO Forge Class
|
* PDO Forge Class
|
||||||
*
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/database/
|
* @link https://codeigniter.com/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_pdo_forge extends CI_DB_forge {
|
class CI_DB_pdo_forge extends CI_DB_forge {
|
||||||
|
|
||||||
@ -50,6 +63,3 @@ class CI_DB_pdo_forge extends CI_DB_forge {
|
|||||||
protected $_drop_table_if = FALSE;
|
protected $_drop_table_if = FALSE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file pdo_forge.php */
|
|
||||||
/* Location: ./system/database/drivers/pdo/pdo_forge.php */
|
|
53
system/database/drivers/pdo/pdo_result.php
Executable file → Normal file
53
system/database/drivers/pdo/pdo_result.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 2.1.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,10 +42,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* This class extends the parent result class: CI_DB_result
|
* This class extends the parent result class: CI_DB_result
|
||||||
*
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
* @since 2.1
|
|
||||||
*/
|
*/
|
||||||
class CI_DB_pdo_result extends CI_DB_result {
|
class CI_DB_pdo_result extends CI_DB_result {
|
||||||
|
|
||||||
@ -93,7 +105,7 @@ class CI_DB_pdo_result extends CI_DB_result {
|
|||||||
{
|
{
|
||||||
// Might trigger an E_WARNING due to not all subdrivers
|
// Might trigger an E_WARNING due to not all subdrivers
|
||||||
// supporting getColumnMeta()
|
// supporting getColumnMeta()
|
||||||
$field_names[$i] = @$this->result_id->getColumnMeta();
|
$field_names[$i] = @$this->result_id->getColumnMeta($i);
|
||||||
$field_names[$i] = $field_names[$i]['name'];
|
$field_names[$i] = $field_names[$i]['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,6 +196,3 @@ class CI_DB_pdo_result extends CI_DB_result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file pdo_result.php */
|
|
||||||
/* Location: ./system/database/drivers/pdo/pdo_result.php */
|
|
50
system/database/drivers/pdo/pdo_utility.php
Executable file → Normal file
50
system/database/drivers/pdo/pdo_utility.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 2.1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 2.1.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -29,9 +40,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
/**
|
/**
|
||||||
* PDO Utility Class
|
* PDO Utility Class
|
||||||
*
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/database/
|
* @link https://codeigniter.com/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_pdo_utility extends CI_DB_utility {
|
class CI_DB_pdo_utility extends CI_DB_utility {
|
||||||
|
|
||||||
@ -48,6 +61,3 @@ class CI_DB_pdo_utility extends CI_DB_utility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file pdo_utility.php */
|
|
||||||
/* Location: ./system/database/drivers/pdo/pdo_utility.php */
|
|
3
system/database/drivers/pdo/subdrivers/index.html
Executable file → Normal file
3
system/database/drivers/pdo/subdrivers/index.html
Executable file → Normal file
@ -1,3 +1,4 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>403 Forbidden</title>
|
<title>403 Forbidden</title>
|
||||||
@ -7,4 +8,4 @@
|
|||||||
<p>Directory access is forbidden.</p>
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
50
system/database/drivers/pdo/subdrivers/pdo_4d_driver.php
Executable file → Normal file
50
system/database/drivers/pdo/subdrivers/pdo_4d_driver.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 3.0.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 3.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -37,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_pdo_4d_driver extends CI_DB_pdo_driver {
|
class CI_DB_pdo_4d_driver extends CI_DB_pdo_driver {
|
||||||
|
|
||||||
@ -147,7 +158,7 @@ class CI_DB_pdo_4d_driver extends CI_DB_pdo_driver {
|
|||||||
* @param string $table
|
* @param string $table
|
||||||
* @param array $values
|
* @param array $values
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function _update($table, $values)
|
protected function _update($table, $values)
|
||||||
{
|
{
|
||||||
$this->qb_limit = FALSE;
|
$this->qb_limit = FALSE;
|
||||||
@ -187,6 +198,3 @@ class CI_DB_pdo_4d_driver extends CI_DB_pdo_driver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file pdo_4d_driver.php */
|
|
||||||
/* Location: ./system/database/drivers/pdo/subdrivers/pdo_4d_driver.php */
|
|
52
system/database/drivers/pdo/subdrivers/pdo_4d_forge.php
Executable file → Normal file
52
system/database/drivers/pdo/subdrivers/pdo_4d_forge.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 2.1.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 3.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -31,9 +42,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
*
|
*
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_pdo_4d_forge extends CI_DB_4d_forge {
|
class CI_DB_pdo_4d_forge extends CI_DB_pdo_forge {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CREATE DATABASE statement
|
* CREATE DATABASE statement
|
||||||
@ -153,7 +164,7 @@ class CI_DB_pdo_4d_forge extends CI_DB_4d_forge {
|
|||||||
$attributes['TYPE'] = 'INT';
|
$attributes['TYPE'] = 'INT';
|
||||||
return;
|
return;
|
||||||
case 'BIGINT':
|
case 'BIGINT':
|
||||||
$attribites['TYPE'] = 'INT64';
|
$attributes['TYPE'] = 'INT64';
|
||||||
return;
|
return;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
@ -204,6 +215,3 @@ class CI_DB_pdo_4d_forge extends CI_DB_4d_forge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file pdo_4d_forge.php */
|
|
||||||
/* Location: ./system/database/drivers/pdo/subdrivers/pdo_4d_forge.php */
|
|
96
system/database/drivers/pdo/subdrivers/pdo_cubrid_driver.php
Executable file → Normal file
96
system/database/drivers/pdo/subdrivers/pdo_cubrid_driver.php
Executable file → Normal file
@ -2,26 +2,37 @@
|
|||||||
/**
|
/**
|
||||||
* CodeIgniter
|
* CodeIgniter
|
||||||
*
|
*
|
||||||
* An open source application development framework for PHP 5.2.4 or newer
|
* An open source application development framework for PHP
|
||||||
*
|
*
|
||||||
* NOTICE OF LICENSE
|
* This content is released under the MIT License (MIT)
|
||||||
*
|
*
|
||||||
* Licensed under the Open Software License version 3.0
|
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||||
*
|
*
|
||||||
* This source file is subject to the Open Software License (OSL 3.0) that is
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* bundled with this package in the files license.txt / license.rst. It is
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
* also available through the world wide web at this URL:
|
* in the Software without restriction, including without limitation the rights
|
||||||
* http://opensource.org/licenses/OSL-3.0
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
* If you did not receive a copy of the license and are unable to obtain it
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
* through the world wide web, please send an email to
|
* furnished to do so, subject to the following conditions:
|
||||||
* licensing@ellislab.com so we can send you a copy immediately.
|
|
||||||
*
|
*
|
||||||
* @package CodeIgniter
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* @author EllisLab Dev Team
|
* all copies or substantial portions of the Software.
|
||||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
|
*
|
||||||
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* @link http://codeigniter.com
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* @since Version 3.0.0
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||||
|
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
|
||||||
|
* @license https://opensource.org/licenses/MIT MIT License
|
||||||
|
* @link https://codeigniter.com
|
||||||
|
* @since Version 3.0.0
|
||||||
* @filesource
|
* @filesource
|
||||||
*/
|
*/
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
@ -37,7 +48,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
|||||||
* @subpackage Drivers
|
* @subpackage Drivers
|
||||||
* @category Database
|
* @category Database
|
||||||
* @author EllisLab Dev Team
|
* @author EllisLab Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link https://codeigniter.com/user_guide/database/
|
||||||
*/
|
*/
|
||||||
class CI_DB_pdo_cubrid_driver extends CI_DB_pdo_driver {
|
class CI_DB_pdo_cubrid_driver extends CI_DB_pdo_driver {
|
||||||
|
|
||||||
@ -131,13 +142,8 @@ class CI_DB_pdo_cubrid_driver extends CI_DB_pdo_driver {
|
|||||||
* @param string $table
|
* @param string $table
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function field_data($table = '')
|
public function field_data($table)
|
||||||
{
|
{
|
||||||
if ($table === '')
|
|
||||||
{
|
|
||||||
return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
|
if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -164,47 +170,6 @@ class CI_DB_pdo_cubrid_driver extends CI_DB_pdo_driver {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* Update_Batch statement
|
|
||||||
*
|
|
||||||
* Generates a platform-specific batch update string from the supplied data
|
|
||||||
*
|
|
||||||
* @param string $table Table name
|
|
||||||
* @param array $values Update data
|
|
||||||
* @param string $index WHERE key
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
protected function _update_batch($table, $values, $index)
|
|
||||||
{
|
|
||||||
$ids = array();
|
|
||||||
foreach ($values as $key => $val)
|
|
||||||
{
|
|
||||||
$ids[] = $val[$index];
|
|
||||||
|
|
||||||
foreach (array_keys($val) as $field)
|
|
||||||
{
|
|
||||||
if ($field !== $index)
|
|
||||||
{
|
|
||||||
$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$cases = '';
|
|
||||||
foreach ($final as $k => $v)
|
|
||||||
{
|
|
||||||
$cases .= $k." = CASE \n"
|
|
||||||
.implode("\n", $v)."\n"
|
|
||||||
.'ELSE '.$k.' END), ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->where($index.' IN('.implode(',', $ids).')', NULL, FALSE);
|
|
||||||
|
|
||||||
return 'UPDATE '.$table.' SET '.substr($cases, 0, -2).$this->_compile_wh('qb_where');
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Truncate statement
|
* Truncate statement
|
||||||
*
|
*
|
||||||
@ -242,6 +207,3 @@ class CI_DB_pdo_cubrid_driver extends CI_DB_pdo_driver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* End of file pdo_cubrid_driver.php */
|
|
||||||
/* Location: ./system/database/drivers/pdo/subdrivers/pdo_cubrid_driver.php */
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user