Christian vor 3 Jahren
Commit
efaa4246b6
100 geänderte Dateien mit 22532 neuen und 0 gelöschten Zeilen
  1. 15 0
      .editorconfig
  2. 31 0
      .gitignore
  3. 15 0
      .htaccess
  4. 6 0
      application/.htaccess
  5. 11 0
      application/cache/index.html
  6. 135 0
      application/config/autoload.php
  7. 523 0
      application/config/config.php
  8. 85 0
      application/config/constants.php
  9. 96 0
      application/config/database.php
  10. 24 0
      application/config/doctypes.php
  11. 114 0
      application/config/foreign_chars.php
  12. 13 0
      application/config/hooks.php
  13. 11 0
      application/config/index.html
  14. 19 0
      application/config/memcached.php
  15. 84 0
      application/config/migration.php
  16. 184 0
      application/config/mimes.php
  17. 14 0
      application/config/profiler.php
  18. 54 0
      application/config/routes.php
  19. 64 0
      application/config/smileys.php
  20. 216 0
      application/config/user_agents.php
  21. 25 0
      application/controllers/Welcome.php
  22. 11 0
      application/controllers/index.html
  23. 11 0
      application/core/index.html
  24. 11 0
      application/helpers/index.html
  25. 11 0
      application/hooks/index.html
  26. 11 0
      application/index.html
  27. 11 0
      application/language/english/index.html
  28. 11 0
      application/language/index.html
  29. 11 0
      application/libraries/index.html
  30. 11 0
      application/logs/index.html
  31. 11 0
      application/models/index.html
  32. 11 0
      application/third_party/index.html
  33. 8 0
      application/views/errors/cli/error_404.php
  34. 8 0
      application/views/errors/cli/error_db.php
  35. 21 0
      application/views/errors/cli/error_exception.php
  36. 8 0
      application/views/errors/cli/error_general.php
  37. 21 0
      application/views/errors/cli/error_php.php
  38. 11 0
      application/views/errors/cli/index.html
  39. 64 0
      application/views/errors/html/error_404.php
  40. 64 0
      application/views/errors/html/error_db.php
  41. 32 0
      application/views/errors/html/error_exception.php
  42. 64 0
      application/views/errors/html/error_general.php
  43. 33 0
      application/views/errors/html/error_php.php
  44. 11 0
      application/views/errors/html/index.html
  45. 11 0
      application/views/errors/index.html
  46. 11 0
      application/views/index.html
  47. 89 0
      application/views/welcome_message.php
  48. 23 0
      composer.json
  49. 93 0
      contributing.md
  50. 315 0
      index.php
  51. 21 0
      license.txt
  52. 70 0
      readme.rst
  53. 6 0
      system/.htaccess
  54. 133 0
      system/core/Benchmark.php
  55. 559 0
      system/core/CodeIgniter.php
  56. 849 0
      system/core/Common.php
  57. 379 0
      system/core/Config.php
  58. 103 0
      system/core/Controller.php
  59. 274 0
      system/core/Exceptions.php
  60. 266 0
      system/core/Hooks.php
  61. 895 0
      system/core/Input.php
  62. 203 0
      system/core/Lang.php
  63. 1415 0
      system/core/Loader.php
  64. 296 0
      system/core/Log.php
  65. 76 0
      system/core/Model.php
  66. 842 0
      system/core/Output.php
  67. 515 0
      system/core/Router.php
  68. 1091 0
      system/core/Security.php
  69. 643 0
      system/core/URI.php
  70. 164 0
      system/core/Utf8.php
  71. 254 0
      system/core/compat/hash.php
  72. 11 0
      system/core/compat/index.html
  73. 149 0
      system/core/compat/mbstring.php
  74. 251 0
      system/core/compat/password.php
  75. 182 0
      system/core/compat/standard.php
  76. 11 0
      system/core/index.html
  77. 218 0
      system/database/DB.php
  78. 221 0
      system/database/DB_cache.php
  79. 1985 0
      system/database/DB_driver.php
  80. 1033 0
      system/database/DB_forge.php
  81. 2808 0
      system/database/DB_query_builder.php
  82. 665 0
      system/database/DB_result.php
  83. 424 0
      system/database/DB_utility.php
  84. 405 0
      system/database/drivers/cubrid/cubrid_driver.php
  85. 230 0
      system/database/drivers/cubrid/cubrid_forge.php
  86. 177 0
      system/database/drivers/cubrid/cubrid_result.php
  87. 79 0
      system/database/drivers/cubrid/cubrid_utility.php
  88. 11 0
      system/database/drivers/cubrid/index.html
  89. 413 0
      system/database/drivers/ibase/ibase_driver.php
  90. 251 0
      system/database/drivers/ibase/ibase_forge.php
  91. 161 0
      system/database/drivers/ibase/ibase_result.php
  92. 69 0
      system/database/drivers/ibase/ibase_utility.php
  93. 11 0
      system/database/drivers/ibase/index.html
  94. 11 0
      system/database/drivers/index.html
  95. 11 0
      system/database/drivers/mssql/index.html
  96. 518 0
      system/database/drivers/mssql/mssql_driver.php
  97. 151 0
      system/database/drivers/mssql/mssql_forge.php
  98. 198 0
      system/database/drivers/mssql/mssql_result.php
  99. 77 0
      system/database/drivers/mssql/mssql_utility.php
  100. 0 0
      system/database/drivers/mysql/index.html

+ 15 - 0
.editorconfig Datei anzeigen

@@ -0,0 +1,15 @@
1
+# top-most EditorConfig file
2
+root = true
3
+
4
+# Unix-style newlines with a newline ending every file
5
+[*]
6
+end_of_line = lf
7
+insert_final_newline = true
8
+
9
+# Matches multiple files with brace expansion notation
10
+# Set default charset
11
+[*]
12
+charset = utf-8
13
+
14
+# Tab indentation (no size specified)
15
+indent_style = tab

+ 31 - 0
.gitignore Datei anzeigen

@@ -0,0 +1,31 @@
1
+.DS_Store
2
+
3
+application/cache/*
4
+!application/cache/index.html
5
+
6
+application/logs/*
7
+!application/logs/index.html
8
+
9
+!application/*/.htaccess
10
+
11
+composer.lock
12
+
13
+user_guide_src/build/*
14
+user_guide_src/cilexer/build/*
15
+user_guide_src/cilexer/dist/*
16
+user_guide_src/cilexer/pycilexer.egg-info/*
17
+/vendor/
18
+
19
+# IDE Files
20
+#-------------------------
21
+/nbproject/
22
+.idea/*
23
+
24
+## Sublime Text cache files
25
+*.tmlanguage.cache
26
+*.tmPreferences.cache
27
+*.stTheme.cache
28
+*.sublime-workspace
29
+*.sublime-project
30
+/tests/tests/
31
+/tests/results/

+ 15 - 0
.htaccess Datei anzeigen

@@ -0,0 +1,15 @@
1
+DirectoryIndex index.php
2
+Options +FollowSymlinks
3
+RewriteEngine on
4
+
5
+# RewriteCond %{HTTP_HOST} !^www\.
6
+# RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
7
+
8
+RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
9
+RewriteCond %{REQUEST_FILENAME} !-f
10
+RewriteCond %{REQUEST_FILENAME} !-d
11
+RewriteRule ^(.*)$ index.php?/$1 [L]
12
+
13
+
14
+# RedirectMatch ^/$ /portal/login/iniciar_sesion
15
+# php_value max_input_vars 5000

+ 6 - 0
application/.htaccess Datei anzeigen

@@ -0,0 +1,6 @@
1
+<IfModule authz_core_module>
2
+    Require all denied
3
+</IfModule>
4
+<IfModule !authz_core_module>
5
+    Deny from all
6
+</IfModule>

+ 11 - 0
application/cache/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 135 - 0
application/config/autoload.php Datei anzeigen

@@ -0,0 +1,135 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+| -------------------------------------------------------------------
6
+| AUTO-LOADER
7
+| -------------------------------------------------------------------
8
+| This file specifies which systems should be loaded by default.
9
+|
10
+| In order to keep the framework as light-weight as possible only the
11
+| absolute minimal resources are loaded by default. For example,
12
+| the database is not connected to automatically since no assumption
13
+| is made regarding whether you intend to use it.  This file lets
14
+| you globally define which systems you would like loaded with every
15
+| request.
16
+|
17
+| -------------------------------------------------------------------
18
+| Instructions
19
+| -------------------------------------------------------------------
20
+|
21
+| These are the things you can load automatically:
22
+|
23
+| 1. Packages
24
+| 2. Libraries
25
+| 3. Drivers
26
+| 4. Helper files
27
+| 5. Custom config files
28
+| 6. Language files
29
+| 7. Models
30
+|
31
+*/
32
+
33
+/*
34
+| -------------------------------------------------------------------
35
+|  Auto-load Packages
36
+| -------------------------------------------------------------------
37
+| Prototype:
38
+|
39
+|  $autoload['packages'] = array(APPPATH.'third_party', '/usr/local/shared');
40
+|
41
+*/
42
+$autoload['packages'] = array();
43
+
44
+/*
45
+| -------------------------------------------------------------------
46
+|  Auto-load Libraries
47
+| -------------------------------------------------------------------
48
+| These are the classes located in system/libraries/ or your
49
+| application/libraries/ directory, with the addition of the
50
+| 'database' library, which is somewhat of a special case.
51
+|
52
+| Prototype:
53
+|
54
+|	$autoload['libraries'] = array('database', 'email', 'session');
55
+|
56
+| You can also supply an alternative library name to be assigned
57
+| in the controller:
58
+|
59
+|	$autoload['libraries'] = array('user_agent' => 'ua');
60
+*/
61
+$autoload['libraries'] = array();
62
+
63
+/*
64
+| -------------------------------------------------------------------
65
+|  Auto-load Drivers
66
+| -------------------------------------------------------------------
67
+| These classes are located in system/libraries/ or in your
68
+| application/libraries/ directory, but are also placed inside their
69
+| own subdirectory and they extend the CI_Driver_Library class. They
70
+| offer multiple interchangeable driver options.
71
+|
72
+| Prototype:
73
+|
74
+|	$autoload['drivers'] = array('cache');
75
+|
76
+| You can also supply an alternative property name to be assigned in
77
+| the controller:
78
+|
79
+|	$autoload['drivers'] = array('cache' => 'cch');
80
+|
81
+*/
82
+$autoload['drivers'] = array();
83
+
84
+/*
85
+| -------------------------------------------------------------------
86
+|  Auto-load Helper Files
87
+| -------------------------------------------------------------------
88
+| Prototype:
89
+|
90
+|	$autoload['helper'] = array('url', 'file');
91
+*/
92
+$autoload['helper'] = array();
93
+
94
+/*
95
+| -------------------------------------------------------------------
96
+|  Auto-load Config files
97
+| -------------------------------------------------------------------
98
+| Prototype:
99
+|
100
+|	$autoload['config'] = array('config1', 'config2');
101
+|
102
+| NOTE: This item is intended for use ONLY if you have created custom
103
+| config files.  Otherwise, leave it blank.
104
+|
105
+*/
106
+$autoload['config'] = array();
107
+
108
+/*
109
+| -------------------------------------------------------------------
110
+|  Auto-load Language files
111
+| -------------------------------------------------------------------
112
+| Prototype:
113
+|
114
+|	$autoload['language'] = array('lang1', 'lang2');
115
+|
116
+| NOTE: Do not include the "_lang" part of your file.  For example
117
+| "codeigniter_lang.php" would be referenced as array('codeigniter');
118
+|
119
+*/
120
+$autoload['language'] = array();
121
+
122
+/*
123
+| -------------------------------------------------------------------
124
+|  Auto-load Models
125
+| -------------------------------------------------------------------
126
+| Prototype:
127
+|
128
+|	$autoload['model'] = array('first_model', 'second_model');
129
+|
130
+| You can also supply an alternative model name to be assigned
131
+| in the controller:
132
+|
133
+|	$autoload['model'] = array('first_model' => 'first');
134
+*/
135
+$autoload['model'] = array();

+ 523 - 0
application/config/config.php Datei anzeigen

@@ -0,0 +1,523 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+|--------------------------------------------------------------------------
6
+| Base Site URL
7
+|--------------------------------------------------------------------------
8
+|
9
+| URL to your CodeIgniter root. Typically this will be your base URL,
10
+| WITH a trailing slash:
11
+|
12
+|	http://example.com/
13
+|
14
+| WARNING: You MUST set this value!
15
+|
16
+| If it is not set, then CodeIgniter will try guess the protocol and path
17
+| your installation, but due to security concerns the hostname will be set
18
+| to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise.
19
+| The auto-detection mechanism exists only for convenience during
20
+| development and MUST NOT be used in production!
21
+|
22
+| If you need to allow multiple domains, remember that this file is still
23
+| a PHP script and you can easily do that on your own.
24
+|
25
+*/
26
+$config['base_url'] = '';
27
+
28
+/*
29
+|--------------------------------------------------------------------------
30
+| Index File
31
+|--------------------------------------------------------------------------
32
+|
33
+| Typically this will be your index.php file, unless you've renamed it to
34
+| something else. If you are using mod_rewrite to remove the page set this
35
+| variable so that it is blank.
36
+|
37
+*/
38
+$config['index_page'] = 'index.php';
39
+
40
+/*
41
+|--------------------------------------------------------------------------
42
+| URI PROTOCOL
43
+|--------------------------------------------------------------------------
44
+|
45
+| This item determines which server global should be used to retrieve the
46
+| URI string.  The default setting of 'REQUEST_URI' works for most servers.
47
+| If your links do not seem to work, try one of the other delicious flavors:
48
+|
49
+| 'REQUEST_URI'    Uses $_SERVER['REQUEST_URI']
50
+| 'QUERY_STRING'   Uses $_SERVER['QUERY_STRING']
51
+| 'PATH_INFO'      Uses $_SERVER['PATH_INFO']
52
+|
53
+| WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
54
+*/
55
+$config['uri_protocol']	= 'REQUEST_URI';
56
+
57
+/*
58
+|--------------------------------------------------------------------------
59
+| URL suffix
60
+|--------------------------------------------------------------------------
61
+|
62
+| This option allows you to add a suffix to all URLs generated by CodeIgniter.
63
+| For more information please see the user guide:
64
+|
65
+| https://codeigniter.com/user_guide/general/urls.html
66
+*/
67
+$config['url_suffix'] = '';
68
+
69
+/*
70
+|--------------------------------------------------------------------------
71
+| Default Language
72
+|--------------------------------------------------------------------------
73
+|
74
+| This determines which set of language files should be used. Make sure
75
+| there is an available translation if you intend to use something other
76
+| than english.
77
+|
78
+*/
79
+$config['language']	= 'english';
80
+
81
+/*
82
+|--------------------------------------------------------------------------
83
+| Default Character Set
84
+|--------------------------------------------------------------------------
85
+|
86
+| This determines which character set is used by default in various methods
87
+| that require a character set to be provided.
88
+|
89
+| See http://php.net/htmlspecialchars for a list of supported charsets.
90
+|
91
+*/
92
+$config['charset'] = 'UTF-8';
93
+
94
+/*
95
+|--------------------------------------------------------------------------
96
+| Enable/Disable System Hooks
97
+|--------------------------------------------------------------------------
98
+|
99
+| If you would like to use the 'hooks' feature you must enable it by
100
+| setting this variable to TRUE (boolean).  See the user guide for details.
101
+|
102
+*/
103
+$config['enable_hooks'] = FALSE;
104
+
105
+/*
106
+|--------------------------------------------------------------------------
107
+| Class Extension Prefix
108
+|--------------------------------------------------------------------------
109
+|
110
+| This item allows you to set the filename/classname prefix when extending
111
+| native libraries.  For more information please see the user guide:
112
+|
113
+| https://codeigniter.com/user_guide/general/core_classes.html
114
+| https://codeigniter.com/user_guide/general/creating_libraries.html
115
+|
116
+*/
117
+$config['subclass_prefix'] = 'MY_';
118
+
119
+/*
120
+|--------------------------------------------------------------------------
121
+| Composer auto-loading
122
+|--------------------------------------------------------------------------
123
+|
124
+| Enabling this setting will tell CodeIgniter to look for a Composer
125
+| package auto-loader script in application/vendor/autoload.php.
126
+|
127
+|	$config['composer_autoload'] = TRUE;
128
+|
129
+| Or if you have your vendor/ directory located somewhere else, you
130
+| can opt to set a specific path as well:
131
+|
132
+|	$config['composer_autoload'] = '/path/to/vendor/autoload.php';
133
+|
134
+| For more information about Composer, please visit http://getcomposer.org/
135
+|
136
+| Note: This will NOT disable or override the CodeIgniter-specific
137
+|	autoloading (application/config/autoload.php)
138
+*/
139
+$config['composer_autoload'] = FALSE;
140
+
141
+/*
142
+|--------------------------------------------------------------------------
143
+| Allowed URL Characters
144
+|--------------------------------------------------------------------------
145
+|
146
+| This lets you specify which characters are permitted within your URLs.
147
+| When someone tries to submit a URL with disallowed characters they will
148
+| get a warning message.
149
+|
150
+| As a security measure you are STRONGLY encouraged to restrict URLs to
151
+| as few characters as possible.  By default only these are allowed: a-z 0-9~%.:_-
152
+|
153
+| Leave blank to allow all characters -- but only if you are insane.
154
+|
155
+| The configured value is actually a regular expression character group
156
+| and it will be executed as: ! preg_match('/^[<permitted_uri_chars>]+$/i
157
+|
158
+| DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
159
+|
160
+*/
161
+$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
162
+
163
+/*
164
+|--------------------------------------------------------------------------
165
+| Enable Query Strings
166
+|--------------------------------------------------------------------------
167
+|
168
+| By default CodeIgniter uses search-engine friendly segment based URLs:
169
+| example.com/who/what/where/
170
+|
171
+| You can optionally enable standard query string based URLs:
172
+| example.com?who=me&what=something&where=here
173
+|
174
+| Options are: TRUE or FALSE (boolean)
175
+|
176
+| The other items let you set the query string 'words' that will
177
+| invoke your controllers and its functions:
178
+| example.com/index.php?c=controller&m=function
179
+|
180
+| Please note that some of the helpers won't work as expected when
181
+| this feature is enabled, since CodeIgniter is designed primarily to
182
+| use segment based URLs.
183
+|
184
+*/
185
+$config['enable_query_strings'] = FALSE;
186
+$config['controller_trigger'] = 'c';
187
+$config['function_trigger'] = 'm';
188
+$config['directory_trigger'] = 'd';
189
+
190
+/*
191
+|--------------------------------------------------------------------------
192
+| Allow $_GET array
193
+|--------------------------------------------------------------------------
194
+|
195
+| By default CodeIgniter enables access to the $_GET array.  If for some
196
+| reason you would like to disable it, set 'allow_get_array' to FALSE.
197
+|
198
+| WARNING: This feature is DEPRECATED and currently available only
199
+|          for backwards compatibility purposes!
200
+|
201
+*/
202
+$config['allow_get_array'] = TRUE;
203
+
204
+/*
205
+|--------------------------------------------------------------------------
206
+| Error Logging Threshold
207
+|--------------------------------------------------------------------------
208
+|
209
+| You can enable error logging by setting a threshold over zero. The
210
+| threshold determines what gets logged. Threshold options are:
211
+|
212
+|	0 = Disables logging, Error logging TURNED OFF
213
+|	1 = Error Messages (including PHP errors)
214
+|	2 = Debug Messages
215
+|	3 = Informational Messages
216
+|	4 = All Messages
217
+|
218
+| You can also pass an array with threshold levels to show individual error types
219
+|
220
+| 	array(2) = Debug Messages, without Error Messages
221
+|
222
+| For a live site you'll usually only enable Errors (1) to be logged otherwise
223
+| your log files will fill up very fast.
224
+|
225
+*/
226
+$config['log_threshold'] = 0;
227
+
228
+/*
229
+|--------------------------------------------------------------------------
230
+| Error Logging Directory Path
231
+|--------------------------------------------------------------------------
232
+|
233
+| Leave this BLANK unless you would like to set something other than the default
234
+| application/logs/ directory. Use a full server path with trailing slash.
235
+|
236
+*/
237
+$config['log_path'] = '';
238
+
239
+/*
240
+|--------------------------------------------------------------------------
241
+| Log File Extension
242
+|--------------------------------------------------------------------------
243
+|
244
+| The default filename extension for log files. The default 'php' allows for
245
+| protecting the log files via basic scripting, when they are to be stored
246
+| under a publicly accessible directory.
247
+|
248
+| Note: Leaving it blank will default to 'php'.
249
+|
250
+*/
251
+$config['log_file_extension'] = '';
252
+
253
+/*
254
+|--------------------------------------------------------------------------
255
+| Log File Permissions
256
+|--------------------------------------------------------------------------
257
+|
258
+| The file system permissions to be applied on newly created log files.
259
+|
260
+| IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal
261
+|            integer notation (i.e. 0700, 0644, etc.)
262
+*/
263
+$config['log_file_permissions'] = 0644;
264
+
265
+/*
266
+|--------------------------------------------------------------------------
267
+| Date Format for Logs
268
+|--------------------------------------------------------------------------
269
+|
270
+| Each item that is logged has an associated date. You can use PHP date
271
+| codes to set your own date formatting
272
+|
273
+*/
274
+$config['log_date_format'] = 'Y-m-d H:i:s';
275
+
276
+/*
277
+|--------------------------------------------------------------------------
278
+| Error Views Directory Path
279
+|--------------------------------------------------------------------------
280
+|
281
+| Leave this BLANK unless you would like to set something other than the default
282
+| application/views/errors/ directory.  Use a full server path with trailing slash.
283
+|
284
+*/
285
+$config['error_views_path'] = '';
286
+
287
+/*
288
+|--------------------------------------------------------------------------
289
+| Cache Directory Path
290
+|--------------------------------------------------------------------------
291
+|
292
+| Leave this BLANK unless you would like to set something other than the default
293
+| application/cache/ directory.  Use a full server path with trailing slash.
294
+|
295
+*/
296
+$config['cache_path'] = '';
297
+
298
+/*
299
+|--------------------------------------------------------------------------
300
+| Cache Include Query String
301
+|--------------------------------------------------------------------------
302
+|
303
+| Whether to take the URL query string into consideration when generating
304
+| output cache files. Valid options are:
305
+|
306
+|	FALSE      = Disabled
307
+|	TRUE       = Enabled, take all query parameters into account.
308
+|	             Please be aware that this may result in numerous cache
309
+|	             files generated for the same page over and over again.
310
+|	array('q') = Enabled, but only take into account the specified list
311
+|	             of query parameters.
312
+|
313
+*/
314
+$config['cache_query_string'] = FALSE;
315
+
316
+/*
317
+|--------------------------------------------------------------------------
318
+| Encryption Key
319
+|--------------------------------------------------------------------------
320
+|
321
+| If you use the Encryption class, you must set an encryption key.
322
+| See the user guide for more info.
323
+|
324
+| https://codeigniter.com/user_guide/libraries/encryption.html
325
+|
326
+*/
327
+$config['encryption_key'] = '';
328
+
329
+/*
330
+|--------------------------------------------------------------------------
331
+| Session Variables
332
+|--------------------------------------------------------------------------
333
+|
334
+| 'sess_driver'
335
+|
336
+|	The storage driver to use: files, database, redis, memcached
337
+|
338
+| 'sess_cookie_name'
339
+|
340
+|	The session cookie name, must contain only [0-9a-z_-] characters
341
+|
342
+| 'sess_expiration'
343
+|
344
+|	The number of SECONDS you want the session to last.
345
+|	Setting to 0 (zero) means expire when the browser is closed.
346
+|
347
+| 'sess_save_path'
348
+|
349
+|	The location to save sessions to, driver dependent.
350
+|
351
+|	For the 'files' driver, it's a path to a writable directory.
352
+|	WARNING: Only absolute paths are supported!
353
+|
354
+|	For the 'database' driver, it's a table name.
355
+|	Please read up the manual for the format with other session drivers.
356
+|
357
+|	IMPORTANT: You are REQUIRED to set a valid save path!
358
+|
359
+| 'sess_match_ip'
360
+|
361
+|	Whether to match the user's IP address when reading the session data.
362
+|
363
+|	WARNING: If you're using the database driver, don't forget to update
364
+|	         your session table's PRIMARY KEY when changing this setting.
365
+|
366
+| 'sess_time_to_update'
367
+|
368
+|	How many seconds between CI regenerating the session ID.
369
+|
370
+| 'sess_regenerate_destroy'
371
+|
372
+|	Whether to destroy session data associated with the old session ID
373
+|	when auto-regenerating the session ID. When set to FALSE, the data
374
+|	will be later deleted by the garbage collector.
375
+|
376
+| Other session cookie settings are shared with the rest of the application,
377
+| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here.
378
+|
379
+*/
380
+$config['sess_driver'] = 'files';
381
+$config['sess_cookie_name'] = 'ci_session';
382
+$config['sess_expiration'] = 7200;
383
+$config['sess_save_path'] = NULL;
384
+$config['sess_match_ip'] = FALSE;
385
+$config['sess_time_to_update'] = 300;
386
+$config['sess_regenerate_destroy'] = FALSE;
387
+
388
+/*
389
+|--------------------------------------------------------------------------
390
+| Cookie Related Variables
391
+|--------------------------------------------------------------------------
392
+|
393
+| 'cookie_prefix'   = Set a cookie name prefix if you need to avoid collisions
394
+| 'cookie_domain'   = Set to .your-domain.com for site-wide cookies
395
+| 'cookie_path'     = Typically will be a forward slash
396
+| 'cookie_secure'   = Cookie will only be set if a secure HTTPS connection exists.
397
+| 'cookie_httponly' = Cookie will only be accessible via HTTP(S) (no javascript)
398
+|
399
+| Note: These settings (with the exception of 'cookie_prefix' and
400
+|       'cookie_httponly') will also affect sessions.
401
+|
402
+*/
403
+$config['cookie_prefix']	= '';
404
+$config['cookie_domain']	= '';
405
+$config['cookie_path']		= '/';
406
+$config['cookie_secure']	= FALSE;
407
+$config['cookie_httponly'] 	= FALSE;
408
+
409
+/*
410
+|--------------------------------------------------------------------------
411
+| Standardize newlines
412
+|--------------------------------------------------------------------------
413
+|
414
+| Determines whether to standardize newline characters in input data,
415
+| meaning to replace \r\n, \r, \n occurrences with the PHP_EOL value.
416
+|
417
+| WARNING: This feature is DEPRECATED and currently available only
418
+|          for backwards compatibility purposes!
419
+|
420
+*/
421
+$config['standardize_newlines'] = FALSE;
422
+
423
+/*
424
+|--------------------------------------------------------------------------
425
+| Global XSS Filtering
426
+|--------------------------------------------------------------------------
427
+|
428
+| Determines whether the XSS filter is always active when GET, POST or
429
+| COOKIE data is encountered
430
+|
431
+| WARNING: This feature is DEPRECATED and currently available only
432
+|          for backwards compatibility purposes!
433
+|
434
+*/
435
+$config['global_xss_filtering'] = FALSE;
436
+
437
+/*
438
+|--------------------------------------------------------------------------
439
+| Cross Site Request Forgery
440
+|--------------------------------------------------------------------------
441
+| Enables a CSRF cookie token to be set. When set to TRUE, token will be
442
+| checked on a submitted form. If you are accepting user data, it is strongly
443
+| recommended CSRF protection be enabled.
444
+|
445
+| 'csrf_token_name' = The token name
446
+| 'csrf_cookie_name' = The cookie name
447
+| 'csrf_expire' = The number in seconds the token should expire.
448
+| 'csrf_regenerate' = Regenerate token on every submission
449
+| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks
450
+*/
451
+$config['csrf_protection'] = FALSE;
452
+$config['csrf_token_name'] = 'csrf_test_name';
453
+$config['csrf_cookie_name'] = 'csrf_cookie_name';
454
+$config['csrf_expire'] = 7200;
455
+$config['csrf_regenerate'] = TRUE;
456
+$config['csrf_exclude_uris'] = array();
457
+
458
+/*
459
+|--------------------------------------------------------------------------
460
+| Output Compression
461
+|--------------------------------------------------------------------------
462
+|
463
+| Enables Gzip output compression for faster page loads.  When enabled,
464
+| the output class will test whether your server supports Gzip.
465
+| Even if it does, however, not all browsers support compression
466
+| so enable only if you are reasonably sure your visitors can handle it.
467
+|
468
+| Only used if zlib.output_compression is turned off in your php.ini.
469
+| Please do not use it together with httpd-level output compression.
470
+|
471
+| VERY IMPORTANT:  If you are getting a blank page when compression is enabled it
472
+| means you are prematurely outputting something to your browser. It could
473
+| even be a line of whitespace at the end of one of your scripts.  For
474
+| compression to work, nothing can be sent before the output buffer is called
475
+| by the output class.  Do not 'echo' any values with compression enabled.
476
+|
477
+*/
478
+$config['compress_output'] = FALSE;
479
+
480
+/*
481
+|--------------------------------------------------------------------------
482
+| Master Time Reference
483
+|--------------------------------------------------------------------------
484
+|
485
+| Options are 'local' or any PHP supported timezone. This preference tells
486
+| the system whether to use your server's local time as the master 'now'
487
+| reference, or convert it to the configured one timezone. See the 'date
488
+| helper' page of the user guide for information regarding date handling.
489
+|
490
+*/
491
+$config['time_reference'] = 'local';
492
+
493
+/*
494
+|--------------------------------------------------------------------------
495
+| Rewrite PHP Short Tags
496
+|--------------------------------------------------------------------------
497
+|
498
+| If your PHP installation does not have short tag support enabled CI
499
+| can rewrite the tags on-the-fly, enabling you to utilize that syntax
500
+| in your view files.  Options are TRUE or FALSE (boolean)
501
+|
502
+| Note: You need to have eval() enabled for this to work.
503
+|
504
+*/
505
+$config['rewrite_short_tags'] = FALSE;
506
+
507
+/*
508
+|--------------------------------------------------------------------------
509
+| Reverse Proxy IPs
510
+|--------------------------------------------------------------------------
511
+|
512
+| If your server is behind a reverse proxy, you must whitelist the proxy
513
+| IP addresses from which CodeIgniter should trust headers such as
514
+| HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify
515
+| the visitor's IP address.
516
+|
517
+| You can use both an array or a comma-separated list of proxy addresses,
518
+| as well as specifying whole subnets. Here are a few examples:
519
+|
520
+| Comma-separated:	'10.0.1.200,192.168.5.0/24'
521
+| Array:		array('10.0.1.200', '192.168.5.0/24')
522
+*/
523
+$config['proxy_ips'] = '';

+ 85 - 0
application/config/constants.php Datei anzeigen

@@ -0,0 +1,85 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+|--------------------------------------------------------------------------
6
+| Display Debug backtrace
7
+|--------------------------------------------------------------------------
8
+|
9
+| If set to TRUE, a backtrace will be displayed along with php errors. If
10
+| error_reporting is disabled, the backtrace will not display, regardless
11
+| of this setting
12
+|
13
+*/
14
+defined('SHOW_DEBUG_BACKTRACE') OR define('SHOW_DEBUG_BACKTRACE', TRUE);
15
+
16
+/*
17
+|--------------------------------------------------------------------------
18
+| File and Directory Modes
19
+|--------------------------------------------------------------------------
20
+|
21
+| These prefs are used when checking and setting modes when working
22
+| with the file system.  The defaults are fine on servers with proper
23
+| security, but you may wish (or even need) to change the values in
24
+| certain environments (Apache running a separate process for each
25
+| user, PHP under CGI with Apache suEXEC, etc.).  Octal values should
26
+| always be used to set the mode correctly.
27
+|
28
+*/
29
+defined('FILE_READ_MODE')  OR define('FILE_READ_MODE', 0644);
30
+defined('FILE_WRITE_MODE') OR define('FILE_WRITE_MODE', 0666);
31
+defined('DIR_READ_MODE')   OR define('DIR_READ_MODE', 0755);
32
+defined('DIR_WRITE_MODE')  OR define('DIR_WRITE_MODE', 0755);
33
+
34
+/*
35
+|--------------------------------------------------------------------------
36
+| File Stream Modes
37
+|--------------------------------------------------------------------------
38
+|
39
+| These modes are used when working with fopen()/popen()
40
+|
41
+*/
42
+defined('FOPEN_READ')                           OR define('FOPEN_READ', 'rb');
43
+defined('FOPEN_READ_WRITE')                     OR define('FOPEN_READ_WRITE', 'r+b');
44
+defined('FOPEN_WRITE_CREATE_DESTRUCTIVE')       OR define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); // truncates existing file data, use with care
45
+defined('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE')  OR define('FOPEN_READ_WRITE_CREATE_DESTRUCTIVE', 'w+b'); // truncates existing file data, use with care
46
+defined('FOPEN_WRITE_CREATE')                   OR define('FOPEN_WRITE_CREATE', 'ab');
47
+defined('FOPEN_READ_WRITE_CREATE')              OR define('FOPEN_READ_WRITE_CREATE', 'a+b');
48
+defined('FOPEN_WRITE_CREATE_STRICT')            OR define('FOPEN_WRITE_CREATE_STRICT', 'xb');
49
+defined('FOPEN_READ_WRITE_CREATE_STRICT')       OR define('FOPEN_READ_WRITE_CREATE_STRICT', 'x+b');
50
+
51
+/*
52
+|--------------------------------------------------------------------------
53
+| Exit Status Codes
54
+|--------------------------------------------------------------------------
55
+|
56
+| Used to indicate the conditions under which the script is exit()ing.
57
+| While there is no universal standard for error codes, there are some
58
+| broad conventions.  Three such conventions are mentioned below, for
59
+| those who wish to make use of them.  The CodeIgniter defaults were
60
+| chosen for the least overlap with these conventions, while still
61
+| leaving room for others to be defined in future versions and user
62
+| applications.
63
+|
64
+| The three main conventions used for determining exit status codes
65
+| are as follows:
66
+|
67
+|    Standard C/C++ Library (stdlibc):
68
+|       http://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
69
+|       (This link also contains other GNU-specific conventions)
70
+|    BSD sysexits.h:
71
+|       http://www.gsp.com/cgi-bin/man.cgi?section=3&topic=sysexits
72
+|    Bash scripting:
73
+|       http://tldp.org/LDP/abs/html/exitcodes.html
74
+|
75
+*/
76
+defined('EXIT_SUCCESS')        OR define('EXIT_SUCCESS', 0); // no errors
77
+defined('EXIT_ERROR')          OR define('EXIT_ERROR', 1); // generic error
78
+defined('EXIT_CONFIG')         OR define('EXIT_CONFIG', 3); // configuration error
79
+defined('EXIT_UNKNOWN_FILE')   OR define('EXIT_UNKNOWN_FILE', 4); // file not found
80
+defined('EXIT_UNKNOWN_CLASS')  OR define('EXIT_UNKNOWN_CLASS', 5); // unknown class
81
+defined('EXIT_UNKNOWN_METHOD') OR define('EXIT_UNKNOWN_METHOD', 6); // unknown class member
82
+defined('EXIT_USER_INPUT')     OR define('EXIT_USER_INPUT', 7); // invalid user input
83
+defined('EXIT_DATABASE')       OR define('EXIT_DATABASE', 8); // database error
84
+defined('EXIT__AUTO_MIN')      OR define('EXIT__AUTO_MIN', 9); // lowest automatically-assigned error code
85
+defined('EXIT__AUTO_MAX')      OR define('EXIT__AUTO_MAX', 125); // highest automatically-assigned error code

+ 96 - 0
application/config/database.php Datei anzeigen

@@ -0,0 +1,96 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+| -------------------------------------------------------------------
6
+| DATABASE CONNECTIVITY SETTINGS
7
+| -------------------------------------------------------------------
8
+| This file will contain the settings needed to access your database.
9
+|
10
+| For complete instructions please consult the 'Database Connection'
11
+| page of the User Guide.
12
+|
13
+| -------------------------------------------------------------------
14
+| EXPLANATION OF VARIABLES
15
+| -------------------------------------------------------------------
16
+|
17
+|	['dsn']      The full DSN string describe a connection to the database.
18
+|	['hostname'] The hostname of your database server.
19
+|	['username'] The username used to connect to the database
20
+|	['password'] The password used to connect to the database
21
+|	['database'] The name of the database you want to connect to
22
+|	['dbdriver'] The database driver. e.g.: mysqli.
23
+|			Currently supported:
24
+|				 cubrid, ibase, mssql, mysql, mysqli, oci8,
25
+|				 odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
26
+|	['dbprefix'] You can add an optional prefix, which will be added
27
+|				 to the table name when using the  Query Builder class
28
+|	['pconnect'] TRUE/FALSE - Whether to use a persistent connection
29
+|	['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
30
+|	['cache_on'] TRUE/FALSE - Enables/disables query caching
31
+|	['cachedir'] The path to the folder where cache files should be stored
32
+|	['char_set'] The character set used in communicating with the database
33
+|	['dbcollat'] The character collation used in communicating with the database
34
+|				 NOTE: For MySQL and MySQLi databases, this setting is only used
35
+| 				 as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
36
+|				 (and in table creation queries made with DB Forge).
37
+| 				 There is an incompatibility in PHP with mysql_real_escape_string() which
38
+| 				 can make your site vulnerable to SQL injection if you are using a
39
+| 				 multi-byte character set and are running versions lower than these.
40
+| 				 Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
41
+|	['swap_pre'] A default table prefix that should be swapped with the dbprefix
42
+|	['encrypt']  Whether or not to use an encrypted connection.
43
+|
44
+|			'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
45
+|			'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
46
+|
47
+|				'ssl_key'    - Path to the private key file
48
+|				'ssl_cert'   - Path to the public key certificate file
49
+|				'ssl_ca'     - Path to the certificate authority file
50
+|				'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format
51
+|				'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
52
+|				'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not
53
+|
54
+|	['compress'] Whether or not to use client compression (MySQL only)
55
+|	['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
56
+|							- good for ensuring strict SQL while developing
57
+|	['ssl_options']	Used to set various SSL options that can be used when making SSL connections.
58
+|	['failover'] array - A array with 0 or more data for connections if the main should fail.
59
+|	['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
60
+| 				NOTE: Disabling this will also effectively disable both
61
+| 				$this->db->last_query() and profiling of DB queries.
62
+| 				When you run a query, with this setting set to TRUE (default),
63
+| 				CodeIgniter will store the SQL statement for debugging purposes.
64
+| 				However, this may cause high memory usage, especially if you run
65
+| 				a lot of SQL queries ... disable this to avoid that problem.
66
+|
67
+| The $active_group variable lets you choose which connection group to
68
+| make active.  By default there is only one group (the 'default' group).
69
+|
70
+| The $query_builder variables lets you determine whether or not to load
71
+| the query builder class.
72
+*/
73
+$active_group = 'default';
74
+$query_builder = TRUE;
75
+
76
+$db['default'] = array(
77
+	'dsn'	=> '',
78
+	'hostname' => 'localhost',
79
+	'username' => '',
80
+	'password' => '',
81
+	'database' => '',
82
+	'dbdriver' => 'mysqli',
83
+	'dbprefix' => '',
84
+	'pconnect' => FALSE,
85
+	'db_debug' => (ENVIRONMENT !== 'production'),
86
+	'cache_on' => FALSE,
87
+	'cachedir' => '',
88
+	'char_set' => 'utf8',
89
+	'dbcollat' => 'utf8_general_ci',
90
+	'swap_pre' => '',
91
+	'encrypt' => FALSE,
92
+	'compress' => FALSE,
93
+	'stricton' => FALSE,
94
+	'failover' => array(),
95
+	'save_queries' => TRUE
96
+);

+ 24 - 0
application/config/doctypes.php Datei anzeigen

@@ -0,0 +1,24 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+$_doctypes = array(
5
+	'xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
6
+	'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
7
+	'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
8
+	'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
9
+	'xhtml-basic11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">',
10
+	'html5' => '<!DOCTYPE html>',
11
+	'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
12
+	'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
13
+	'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">',
14
+	'mathml1' => '<!DOCTYPE math SYSTEM "http://www.w3.org/Math/DTD/mathml1/mathml.dtd">',
15
+	'mathml2' => '<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">',
16
+	'svg10' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">',
17
+	'svg11' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">',
18
+	'svg11-basic' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">',
19
+	'svg11-tiny' => '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">',
20
+	'xhtml-math-svg-xh' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
21
+	'xhtml-math-svg-sh' => '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
22
+	'xhtml-rdfa-1' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
23
+	'xhtml-rdfa-2' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.1//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd">'
24
+);

+ 114 - 0
application/config/foreign_chars.php Datei anzeigen

@@ -0,0 +1,114 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+| -------------------------------------------------------------------
6
+| Foreign Characters
7
+| -------------------------------------------------------------------
8
+| This file contains an array of foreign characters for transliteration
9
+| conversion used by the Text helper
10
+|
11
+*/
12
+$foreign_characters = array(
13
+	'/ä|æ|ǽ/' => 'ae',
14
+	'/ö|œ/' => 'oe',
15
+	'/ü/' => 'ue',
16
+	'/Ä/' => 'Ae',
17
+	'/Ü/' => 'Ue',
18
+	'/Ö/' => 'Oe',
19
+	'/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|Α|Ά|Ả|Ạ|Ầ|Ẫ|Ẩ|Ậ|Ằ|Ắ|Ẵ|Ẳ|Ặ|А/' => 'A',
20
+	'/à|á|â|ã|å|ǻ|ā|ă|ą|ǎ|ª|α|ά|ả|ạ|ầ|ấ|ẫ|ẩ|ậ|ằ|ắ|ẵ|ẳ|ặ|а/' => 'a',
21
+	'/Б/' => 'B',
22
+	'/б/' => 'b',
23
+	'/Ç|Ć|Ĉ|Ċ|Č/' => 'C',
24
+	'/ç|ć|ĉ|ċ|č/' => 'c',
25
+	'/Д|Δ/' => 'D',
26
+	'/д|δ/' => 'd',
27
+	'/Ð|Ď|Đ/' => 'Dj',
28
+	'/ð|ď|đ/' => 'dj',
29
+	'/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Ε|Έ|Ẽ|Ẻ|Ẹ|Ề|Ế|Ễ|Ể|Ệ|Е|Э/' => 'E',
30
+	'/è|é|ê|ë|ē|ĕ|ė|ę|ě|έ|ε|ẽ|ẻ|ẹ|ề|ế|ễ|ể|ệ|е|э/' => 'e',
31
+	'/Ф/' => 'F',
32
+	'/ф/' => 'f',
33
+	'/Ĝ|Ğ|Ġ|Ģ|Γ|Г|Ґ/' => 'G',
34
+	'/ĝ|ğ|ġ|ģ|γ|г|ґ/' => 'g',
35
+	'/Ĥ|Ħ/' => 'H',
36
+	'/ĥ|ħ/' => 'h',
37
+	'/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|Η|Ή|Ί|Ι|Ϊ|Ỉ|Ị|И|Ы/' => 'I',
38
+	'/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|η|ή|ί|ι|ϊ|ỉ|ị|и|ы|ї/' => 'i',
39
+	'/Ĵ/' => 'J',
40
+	'/ĵ/' => 'j',
41
+	'/Θ/' => 'TH',
42
+	'/θ/' => 'th',
43
+	'/Ķ|Κ|К/' => 'K',
44
+	'/ķ|κ|к/' => 'k',
45
+	'/Ĺ|Ļ|Ľ|Ŀ|Ł|Λ|Л/' => 'L',
46
+	'/ĺ|ļ|ľ|ŀ|ł|λ|л/' => 'l',
47
+	'/М/' => 'M',
48
+	'/м/' => 'm',
49
+	'/Ñ|Ń|Ņ|Ň|Ν|Н/' => 'N',
50
+	'/ñ|ń|ņ|ň|ʼn|ν|н/' => 'n',
51
+	'/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ|Ỏ|Ọ|Ồ|Ố|Ỗ|Ổ|Ộ|Ờ|Ớ|Ỡ|Ở|Ợ|О/' => 'O',
52
+	'/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ|ỏ|ọ|ồ|ố|ỗ|ổ|ộ|ờ|ớ|ỡ|ở|ợ|о/' => 'o',
53
+	'/П/' => 'P',
54
+	'/п/' => 'p',
55
+	'/Ŕ|Ŗ|Ř|Ρ|Р/' => 'R',
56
+	'/ŕ|ŗ|ř|ρ|р/' => 'r',
57
+	'/Ś|Ŝ|Ş|Ș|Š|Σ|С/' => 'S',
58
+	'/ś|ŝ|ş|ș|š|ſ|σ|ς|с/' => 's',
59
+	'/Ț|Ţ|Ť|Ŧ|Τ|Т/' => 'T',
60
+	'/ț|ţ|ť|ŧ|τ|т/' => 't',
61
+	'/Þ|þ/' => 'th',
62
+	'/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U',
63
+	'/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u',
64
+	'/Ƴ|Ɏ|Ỵ|Ẏ|Ӳ|Ӯ|Ў|Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y',
65
+	'/ẙ|ʏ|ƴ|ɏ|ỵ|ẏ|ӳ|ӯ|ў|ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y',
66
+	'/В/' => 'V',
67
+	'/в/' => 'v',
68
+	'/Ŵ/' => 'W',
69
+	'/ŵ/' => 'w',
70
+	'/Φ/' => 'F',
71
+	'/φ/' => 'f',
72
+	'/Χ/' => 'CH',
73
+	'/χ/' => 'ch',
74
+	'/Ź|Ż|Ž|Ζ|З/' => 'Z',
75
+	'/ź|ż|ž|ζ|з/' => 'z',
76
+	'/Æ|Ǽ/' => 'AE',
77
+	'/ß/' => 'ss',
78
+	'/IJ/' => 'IJ',
79
+	'/ij/' => 'ij',
80
+	'/Œ/' => 'OE',
81
+	'/ƒ/' => 'f',
82
+	'/Ξ/' => 'KS',
83
+	'/ξ/' => 'ks',
84
+	'/Π/' => 'P',
85
+	'/π/' => 'p',
86
+	'/Β/' => 'V',
87
+	'/β/' => 'v',
88
+	'/Μ/' => 'M',
89
+	'/μ/' => 'm',
90
+	'/Ψ/' => 'PS',
91
+	'/ψ/' => 'ps',
92
+	'/Ё/' => 'Yo',
93
+	'/ё/' => 'yo',
94
+	'/Є/' => 'Ye',
95
+	'/є/' => 'ye',
96
+	'/Ї/' => 'Yi',
97
+	'/Ж/' => 'Zh',
98
+	'/ж/' => 'zh',
99
+	'/Х/' => 'Kh',
100
+	'/х/' => 'kh',
101
+	'/Ц/' => 'Ts',
102
+	'/ц/' => 'ts',
103
+	'/Ч/' => 'Ch',
104
+	'/ч/' => 'ch',
105
+	'/Ш/' => 'Sh',
106
+	'/ш/' => 'sh',
107
+	'/Щ/' => 'Shch',
108
+	'/щ/' => 'shch',
109
+	'/Ъ|ъ|Ь|ь/' => '',
110
+	'/Ю/' => 'Yu',
111
+	'/ю/' => 'yu',
112
+	'/Я/' => 'Ya',
113
+	'/я/' => 'ya'
114
+);

+ 13 - 0
application/config/hooks.php Datei anzeigen

@@ -0,0 +1,13 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+| -------------------------------------------------------------------------
6
+| Hooks
7
+| -------------------------------------------------------------------------
8
+| This file lets you define "hooks" to extend CI without hacking the core
9
+| files.  Please see the user guide for info:
10
+|
11
+|	https://codeigniter.com/user_guide/general/hooks.html
12
+|
13
+*/

+ 11 - 0
application/config/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 19 - 0
application/config/memcached.php Datei anzeigen

@@ -0,0 +1,19 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+| -------------------------------------------------------------------------
6
+| Memcached settings
7
+| -------------------------------------------------------------------------
8
+| Your Memcached servers can be specified below.
9
+|
10
+|	See: https://codeigniter.com/user_guide/libraries/caching.html#memcached
11
+|
12
+*/
13
+$config = array(
14
+	'default' => array(
15
+		'hostname' => '127.0.0.1',
16
+		'port'     => '11211',
17
+		'weight'   => '1',
18
+	),
19
+);

+ 84 - 0
application/config/migration.php Datei anzeigen

@@ -0,0 +1,84 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+|--------------------------------------------------------------------------
6
+| Enable/Disable Migrations
7
+|--------------------------------------------------------------------------
8
+|
9
+| Migrations are disabled by default for security reasons.
10
+| You should enable migrations whenever you intend to do a schema migration
11
+| and disable it back when you're done.
12
+|
13
+*/
14
+$config['migration_enabled'] = FALSE;
15
+
16
+/*
17
+|--------------------------------------------------------------------------
18
+| Migration Type
19
+|--------------------------------------------------------------------------
20
+|
21
+| Migration file names may be based on a sequential identifier or on
22
+| a timestamp. Options are:
23
+|
24
+|   'sequential' = Sequential migration naming (001_add_blog.php)
25
+|   'timestamp'  = Timestamp migration naming (20121031104401_add_blog.php)
26
+|                  Use timestamp format YYYYMMDDHHIISS.
27
+|
28
+| Note: If this configuration value is missing the Migration library
29
+|       defaults to 'sequential' for backward compatibility with CI2.
30
+|
31
+*/
32
+$config['migration_type'] = 'timestamp';
33
+
34
+/*
35
+|--------------------------------------------------------------------------
36
+| Migrations table
37
+|--------------------------------------------------------------------------
38
+|
39
+| This is the name of the table that will store the current migrations state.
40
+| When migrations runs it will store in a database table which migration
41
+| level the system is at. It then compares the migration level in this
42
+| table to the $config['migration_version'] if they are not the same it
43
+| will migrate up. This must be set.
44
+|
45
+*/
46
+$config['migration_table'] = 'migrations';
47
+
48
+/*
49
+|--------------------------------------------------------------------------
50
+| Auto Migrate To Latest
51
+|--------------------------------------------------------------------------
52
+|
53
+| If this is set to TRUE when you load the migrations class and have
54
+| $config['migration_enabled'] set to TRUE the system will auto migrate
55
+| to your latest migration (whatever $config['migration_version'] is
56
+| set to). This way you do not have to call migrations anywhere else
57
+| in your code to have the latest migration.
58
+|
59
+*/
60
+$config['migration_auto_latest'] = FALSE;
61
+
62
+/*
63
+|--------------------------------------------------------------------------
64
+| Migrations version
65
+|--------------------------------------------------------------------------
66
+|
67
+| This is used to set migration version that the file system should be on.
68
+| If you run $this->migration->current() this is the version that schema will
69
+| be upgraded / downgraded to.
70
+|
71
+*/
72
+$config['migration_version'] = 0;
73
+
74
+/*
75
+|--------------------------------------------------------------------------
76
+| Migrations Path
77
+|--------------------------------------------------------------------------
78
+|
79
+| Path to your migrations folder.
80
+| Typically, it will be within your application path.
81
+| Also, writing permission is required within the migrations path.
82
+|
83
+*/
84
+$config['migration_path'] = APPPATH.'migrations/';

+ 184 - 0
application/config/mimes.php Datei anzeigen

@@ -0,0 +1,184 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+| -------------------------------------------------------------------
6
+| MIME TYPES
7
+| -------------------------------------------------------------------
8
+| This file contains an array of mime types.  It is used by the
9
+| Upload class to help identify allowed file types.
10
+|
11
+*/
12
+return array(
13
+	'hqx'	=>	array('application/mac-binhex40', 'application/mac-binhex', 'application/x-binhex40', 'application/x-mac-binhex40'),
14
+	'cpt'	=>	'application/mac-compactpro',
15
+	'csv'	=>	array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel', 'text/plain'),
16
+	'bin'	=>	array('application/macbinary', 'application/mac-binary', 'application/octet-stream', 'application/x-binary', 'application/x-macbinary'),
17
+	'dms'	=>	'application/octet-stream',
18
+	'lha'	=>	'application/octet-stream',
19
+	'lzh'	=>	'application/octet-stream',
20
+	'exe'	=>	array('application/octet-stream', 'application/x-msdownload'),
21
+	'class'	=>	'application/octet-stream',
22
+	'psd'	=>	array('application/x-photoshop', 'image/vnd.adobe.photoshop'),
23
+	'so'	=>	'application/octet-stream',
24
+	'sea'	=>	'application/octet-stream',
25
+	'dll'	=>	'application/octet-stream',
26
+	'oda'	=>	'application/oda',
27
+	'pdf'	=>	array('application/pdf', 'application/force-download', 'application/x-download', 'binary/octet-stream'),
28
+	'ai'	=>	array('application/pdf', 'application/postscript'),
29
+	'eps'	=>	'application/postscript',
30
+	'ps'	=>	'application/postscript',
31
+	'smi'	=>	'application/smil',
32
+	'smil'	=>	'application/smil',
33
+	'mif'	=>	'application/vnd.mif',
34
+	'xls'	=>	array('application/vnd.ms-excel', 'application/msexcel', 'application/x-msexcel', 'application/x-ms-excel', 'application/x-excel', 'application/x-dos_ms_excel', 'application/xls', 'application/x-xls', 'application/excel', 'application/download', 'application/vnd.ms-office', 'application/msword'),
35
+	'ppt'	=>	array('application/powerpoint', 'application/vnd.ms-powerpoint', 'application/vnd.ms-office', 'application/msword'),
36
+	'pptx'	=> 	array('application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/x-zip', 'application/zip'),
37
+	'wbxml'	=>	'application/wbxml',
38
+	'wmlc'	=>	'application/wmlc',
39
+	'dcr'	=>	'application/x-director',
40
+	'dir'	=>	'application/x-director',
41
+	'dxr'	=>	'application/x-director',
42
+	'dvi'	=>	'application/x-dvi',
43
+	'gtar'	=>	'application/x-gtar',
44
+	'gz'	=>	'application/x-gzip',
45
+	'gzip'  =>	'application/x-gzip',
46
+	'php'	=>	array('application/x-httpd-php', 'application/php', 'application/x-php', 'text/php', 'text/x-php', 'application/x-httpd-php-source'),
47
+	'php4'	=>	'application/x-httpd-php',
48
+	'php3'	=>	'application/x-httpd-php',
49
+	'phtml'	=>	'application/x-httpd-php',
50
+	'phps'	=>	'application/x-httpd-php-source',
51
+	'js'	=>	array('application/x-javascript', 'text/plain'),
52
+	'swf'	=>	'application/x-shockwave-flash',
53
+	'sit'	=>	'application/x-stuffit',
54
+	'tar'	=>	'application/x-tar',
55
+	'tgz'	=>	array('application/x-tar', 'application/x-gzip-compressed'),
56
+	'z'	=>	'application/x-compress',
57
+	'xhtml'	=>	'application/xhtml+xml',
58
+	'xht'	=>	'application/xhtml+xml',
59
+	'zip'	=>	array('application/x-zip', 'application/zip', 'application/x-zip-compressed', 'application/s-compressed', 'multipart/x-zip'),
60
+	'rar'	=>	array('application/x-rar', 'application/rar', 'application/x-rar-compressed'),
61
+	'mid'	=>	'audio/midi',
62
+	'midi'	=>	'audio/midi',
63
+	'mpga'	=>	'audio/mpeg',
64
+	'mp2'	=>	'audio/mpeg',
65
+	'mp3'	=>	array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
66
+	'aif'	=>	array('audio/x-aiff', 'audio/aiff'),
67
+	'aiff'	=>	array('audio/x-aiff', 'audio/aiff'),
68
+	'aifc'	=>	'audio/x-aiff',
69
+	'ram'	=>	'audio/x-pn-realaudio',
70
+	'rm'	=>	'audio/x-pn-realaudio',
71
+	'rpm'	=>	'audio/x-pn-realaudio-plugin',
72
+	'ra'	=>	'audio/x-realaudio',
73
+	'rv'	=>	'video/vnd.rn-realvideo',
74
+	'wav'	=>	array('audio/x-wav', 'audio/wave', 'audio/wav'),
75
+	'bmp'	=>	array('image/bmp', 'image/x-bmp', 'image/x-bitmap', 'image/x-xbitmap', 'image/x-win-bitmap', 'image/x-windows-bmp', 'image/ms-bmp', 'image/x-ms-bmp', 'application/bmp', 'application/x-bmp', 'application/x-win-bitmap'),
76
+	'gif'	=>	'image/gif',
77
+	'jpeg'	=>	array('image/jpeg', 'image/pjpeg'),
78
+	'jpg'	=>	array('image/jpeg', 'image/pjpeg'),
79
+	'jpe'	=>	array('image/jpeg', 'image/pjpeg'),
80
+	'jp2'	=>	array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
81
+	'j2k'	=>	array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
82
+	'jpf'	=>	array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
83
+	'jpg2'	=>	array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
84
+	'jpx'	=>	array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
85
+	'jpm'	=>	array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
86
+	'mj2'	=>	array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
87
+	'mjp2'	=>	array('image/jp2', 'video/mj2', 'image/jpx', 'image/jpm'),
88
+	'png'	=>	array('image/png',  'image/x-png'),
89
+	'tiff'	=>	'image/tiff',
90
+	'tif'	=>	'image/tiff',
91
+	'css'	=>	array('text/css', 'text/plain'),
92
+	'html'	=>	array('text/html', 'text/plain'),
93
+	'htm'	=>	array('text/html', 'text/plain'),
94
+	'shtml'	=>	array('text/html', 'text/plain'),
95
+	'txt'	=>	'text/plain',
96
+	'text'	=>	'text/plain',
97
+	'log'	=>	array('text/plain', 'text/x-log'),
98
+	'rtx'	=>	'text/richtext',
99
+	'rtf'	=>	'text/rtf',
100
+	'xml'	=>	array('application/xml', 'text/xml', 'text/plain'),
101
+	'xsl'	=>	array('application/xml', 'text/xsl', 'text/xml'),
102
+	'mpeg'	=>	'video/mpeg',
103
+	'mpg'	=>	'video/mpeg',
104
+	'mpe'	=>	'video/mpeg',
105
+	'qt'	=>	'video/quicktime',
106
+	'mov'	=>	'video/quicktime',
107
+	'avi'	=>	array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'),
108
+	'movie'	=>	'video/x-sgi-movie',
109
+	'doc'	=>	array('application/msword', 'application/vnd.ms-office'),
110
+	'docx'	=>	array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'),
111
+	'dot'	=>	array('application/msword', 'application/vnd.ms-office'),
112
+	'dotx'	=>	array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'),
113
+	'xlsx'	=>	array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'),
114
+	'word'	=>	array('application/msword', 'application/octet-stream'),
115
+	'xl'	=>	'application/excel',
116
+	'eml'	=>	'message/rfc822',
117
+	'json'  =>	array('application/json', 'text/json'),
118
+	'pem'   =>	array('application/x-x509-user-cert', 'application/x-pem-file', 'application/octet-stream'),
119
+	'p10'   =>	array('application/x-pkcs10', 'application/pkcs10'),
120
+	'p12'   =>	'application/x-pkcs12',
121
+	'p7a'   =>	'application/x-pkcs7-signature',
122
+	'p7c'   =>	array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
123
+	'p7m'   =>	array('application/pkcs7-mime', 'application/x-pkcs7-mime'),
124
+	'p7r'   =>	'application/x-pkcs7-certreqresp',
125
+	'p7s'   =>	'application/pkcs7-signature',
126
+	'crt'   =>	array('application/x-x509-ca-cert', 'application/x-x509-user-cert', 'application/pkix-cert'),
127
+	'crl'   =>	array('application/pkix-crl', 'application/pkcs-crl'),
128
+	'der'   =>	'application/x-x509-ca-cert',
129
+	'kdb'   =>	'application/octet-stream',
130
+	'pgp'   =>	'application/pgp',
131
+	'gpg'   =>	'application/gpg-keys',
132
+	'sst'   =>	'application/octet-stream',
133
+	'csr'   =>	'application/octet-stream',
134
+	'rsa'   =>	'application/x-pkcs7',
135
+	'cer'   =>	array('application/pkix-cert', 'application/x-x509-ca-cert'),
136
+	'3g2'   =>	'video/3gpp2',
137
+	'3gp'   =>	array('video/3gp', 'video/3gpp'),
138
+	'mp4'   =>	'video/mp4',
139
+	'm4a'   =>	'audio/x-m4a',
140
+	'f4v'   =>	array('video/mp4', 'video/x-f4v'),
141
+	'flv'	=>	'video/x-flv',
142
+	'webm'	=>	'video/webm',
143
+	'aac'   =>	array('audio/x-aac', 'audio/aac'),
144
+	'm4u'   =>	'application/vnd.mpegurl',
145
+	'm3u'   =>	'text/plain',
146
+	'xspf'  =>	'application/xspf+xml',
147
+	'vlc'   =>	'application/videolan',
148
+	'wmv'   =>	array('video/x-ms-wmv', 'video/x-ms-asf'),
149
+	'au'    =>	'audio/x-au',
150
+	'ac3'   =>	'audio/ac3',
151
+	'flac'  =>	'audio/x-flac',
152
+	'ogg'   =>	array('audio/ogg', 'video/ogg', 'application/ogg'),
153
+	'kmz'	=>	array('application/vnd.google-earth.kmz', 'application/zip', 'application/x-zip'),
154
+	'kml'	=>	array('application/vnd.google-earth.kml+xml', 'application/xml', 'text/xml'),
155
+	'ics'	=>	'text/calendar',
156
+	'ical'	=>	'text/calendar',
157
+	'zsh'	=>	'text/x-scriptzsh',
158
+	'7z'	=>	array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
159
+	'7zip'	=>	array('application/x-7z-compressed', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'),
160
+	'cdr'	=>	array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'),
161
+	'wma'	=>	array('audio/x-ms-wma', 'video/x-ms-asf'),
162
+	'jar'	=>	array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'),
163
+	'svg'	=>	array('image/svg+xml', 'application/xml', 'text/xml'),
164
+	'vcf'	=>	'text/x-vcard',
165
+	'srt'	=>	array('text/srt', 'text/plain'),
166
+	'vtt'	=>	array('text/vtt', 'text/plain'),
167
+	'ico'	=>	array('image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon'),
168
+	'odc'	=>	'application/vnd.oasis.opendocument.chart',
169
+	'otc'	=>	'application/vnd.oasis.opendocument.chart-template',
170
+	'odf'	=>	'application/vnd.oasis.opendocument.formula',
171
+	'otf'	=>	'application/vnd.oasis.opendocument.formula-template',
172
+	'odg'	=>	'application/vnd.oasis.opendocument.graphics',
173
+	'otg'	=>	'application/vnd.oasis.opendocument.graphics-template',
174
+	'odi'	=>	'application/vnd.oasis.opendocument.image',
175
+	'oti'	=>	'application/vnd.oasis.opendocument.image-template',
176
+	'odp'	=>	'application/vnd.oasis.opendocument.presentation',
177
+	'otp'	=>	'application/vnd.oasis.opendocument.presentation-template',
178
+	'ods'	=>	'application/vnd.oasis.opendocument.spreadsheet',
179
+	'ots'	=>	'application/vnd.oasis.opendocument.spreadsheet-template',
180
+	'odt'	=>	'application/vnd.oasis.opendocument.text',
181
+	'odm'	=>	'application/vnd.oasis.opendocument.text-master',
182
+	'ott'	=>	'application/vnd.oasis.opendocument.text-template',
183
+	'oth'	=>	'application/vnd.oasis.opendocument.text-web'
184
+);

+ 14 - 0
application/config/profiler.php Datei anzeigen

@@ -0,0 +1,14 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+| -------------------------------------------------------------------------
6
+| Profiler Sections
7
+| -------------------------------------------------------------------------
8
+| This file lets you determine whether or not various sections of Profiler
9
+| data are displayed when the Profiler is enabled.
10
+| Please see the user guide for info:
11
+|
12
+|	https://codeigniter.com/user_guide/general/profiling.html
13
+|
14
+*/

+ 54 - 0
application/config/routes.php Datei anzeigen

@@ -0,0 +1,54 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+| -------------------------------------------------------------------------
6
+| URI ROUTING
7
+| -------------------------------------------------------------------------
8
+| This file lets you re-map URI requests to specific controller functions.
9
+|
10
+| Typically there is a one-to-one relationship between a URL string
11
+| and its corresponding controller class/method. The segments in a
12
+| URL normally follow this pattern:
13
+|
14
+|	example.com/class/method/id/
15
+|
16
+| In some instances, however, you may want to remap this relationship
17
+| so that a different class/function is called than the one
18
+| corresponding to the URL.
19
+|
20
+| Please see the user guide for complete details:
21
+|
22
+|	https://codeigniter.com/user_guide/general/routing.html
23
+|
24
+| -------------------------------------------------------------------------
25
+| RESERVED ROUTES
26
+| -------------------------------------------------------------------------
27
+|
28
+| There are three reserved routes:
29
+|
30
+|	$route['default_controller'] = 'welcome';
31
+|
32
+| This route indicates which controller class should be loaded if the
33
+| URI contains no data. In the above example, the "welcome" class
34
+| would be loaded.
35
+|
36
+|	$route['404_override'] = 'errors/page_missing';
37
+|
38
+| This route will tell the Router which controller/method to use if those
39
+| provided in the URL cannot be matched to a valid route.
40
+|
41
+|	$route['translate_uri_dashes'] = FALSE;
42
+|
43
+| This is not exactly a route, but allows you to automatically route
44
+| controller and method names that contain dashes. '-' isn't a valid
45
+| class or method name character, so it requires translation.
46
+| When you set this option to TRUE, it will replace ALL dashes in the
47
+| controller and method URI segments.
48
+|
49
+| Examples:	my-controller/index	-> my_controller/index
50
+|		my-controller/my-method	-> my_controller/my_method
51
+*/
52
+$route['default_controller'] = 'welcome';
53
+$route['404_override'] = '';
54
+$route['translate_uri_dashes'] = FALSE;

+ 64 - 0
application/config/smileys.php Datei anzeigen

@@ -0,0 +1,64 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+| -------------------------------------------------------------------
6
+| SMILEYS
7
+| -------------------------------------------------------------------
8
+| This file contains an array of smileys for use with the emoticon helper.
9
+| Individual images can be used to replace multiple smileys.  For example:
10
+| :-) and :) use the same image replacement.
11
+|
12
+| Please see user guide for more info:
13
+| https://codeigniter.com/user_guide/helpers/smiley_helper.html
14
+|
15
+*/
16
+$smileys = array(
17
+
18
+//	smiley			image name						width	height	alt
19
+
20
+	':-)'			=>	array('grin.gif',			'19',	'19',	'grin'),
21
+	':lol:'			=>	array('lol.gif',			'19',	'19',	'LOL'),
22
+	':cheese:'		=>	array('cheese.gif',			'19',	'19',	'cheese'),
23
+	':)'			=>	array('smile.gif',			'19',	'19',	'smile'),
24
+	';-)'			=>	array('wink.gif',			'19',	'19',	'wink'),
25
+	';)'			=>	array('wink.gif',			'19',	'19',	'wink'),
26
+	':smirk:'		=>	array('smirk.gif',			'19',	'19',	'smirk'),
27
+	':roll:'		=>	array('rolleyes.gif',		'19',	'19',	'rolleyes'),
28
+	':-S'			=>	array('confused.gif',		'19',	'19',	'confused'),
29
+	':wow:'			=>	array('surprise.gif',		'19',	'19',	'surprised'),
30
+	':bug:'			=>	array('bigsurprise.gif',	'19',	'19',	'big surprise'),
31
+	':-P'			=>	array('tongue_laugh.gif',	'19',	'19',	'tongue laugh'),
32
+	'%-P'			=>	array('tongue_rolleye.gif',	'19',	'19',	'tongue rolleye'),
33
+	';-P'			=>	array('tongue_wink.gif',	'19',	'19',	'tongue wink'),
34
+	':P'			=>	array('raspberry.gif',		'19',	'19',	'raspberry'),
35
+	':blank:'		=>	array('blank.gif',			'19',	'19',	'blank stare'),
36
+	':long:'		=>	array('longface.gif',		'19',	'19',	'long face'),
37
+	':ohh:'			=>	array('ohh.gif',			'19',	'19',	'ohh'),
38
+	':grrr:'		=>	array('grrr.gif',			'19',	'19',	'grrr'),
39
+	':gulp:'		=>	array('gulp.gif',			'19',	'19',	'gulp'),
40
+	'8-/'			=>	array('ohoh.gif',			'19',	'19',	'oh oh'),
41
+	':down:'		=>	array('downer.gif',			'19',	'19',	'downer'),
42
+	':red:'			=>	array('embarrassed.gif',	'19',	'19',	'red face'),
43
+	':sick:'		=>	array('sick.gif',			'19',	'19',	'sick'),
44
+	':shut:'		=>	array('shuteye.gif',		'19',	'19',	'shut eye'),
45
+	':-/'			=>	array('hmm.gif',			'19',	'19',	'hmmm'),
46
+	'>:('			=>	array('mad.gif',			'19',	'19',	'mad'),
47
+	':mad:'			=>	array('mad.gif',			'19',	'19',	'mad'),
48
+	'>:-('			=>	array('angry.gif',			'19',	'19',	'angry'),
49
+	':angry:'		=>	array('angry.gif',			'19',	'19',	'angry'),
50
+	':zip:'			=>	array('zip.gif',			'19',	'19',	'zipper'),
51
+	':kiss:'		=>	array('kiss.gif',			'19',	'19',	'kiss'),
52
+	':ahhh:'		=>	array('shock.gif',			'19',	'19',	'shock'),
53
+	':coolsmile:'	=>	array('shade_smile.gif',	'19',	'19',	'cool smile'),
54
+	':coolsmirk:'	=>	array('shade_smirk.gif',	'19',	'19',	'cool smirk'),
55
+	':coolgrin:'	=>	array('shade_grin.gif',		'19',	'19',	'cool grin'),
56
+	':coolhmm:'		=>	array('shade_hmm.gif',		'19',	'19',	'cool hmm'),
57
+	':coolmad:'		=>	array('shade_mad.gif',		'19',	'19',	'cool mad'),
58
+	':coolcheese:'	=>	array('shade_cheese.gif',	'19',	'19',	'cool cheese'),
59
+	':vampire:'		=>	array('vampire.gif',		'19',	'19',	'vampire'),
60
+	':snake:'		=>	array('snake.gif',			'19',	'19',	'snake'),
61
+	':exclaim:'		=>	array('exclaim.gif',		'19',	'19',	'exclaim'),
62
+	':question:'	=>	array('question.gif',		'19',	'19',	'question')
63
+
64
+);

+ 216 - 0
application/config/user_agents.php Datei anzeigen

@@ -0,0 +1,216 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+/*
5
+| -------------------------------------------------------------------
6
+| USER AGENT TYPES
7
+| -------------------------------------------------------------------
8
+| This file contains four arrays of user agent data. It is used by the
9
+| User Agent Class to help identify browser, platform, robot, and
10
+| mobile device data. The array keys are used to identify the device
11
+| and the array values are used to set the actual name of the item.
12
+*/
13
+$platforms = array(
14
+	'windows nt 10.0'	=> 'Windows 10',
15
+	'windows nt 6.3'	=> 'Windows 8.1',
16
+	'windows nt 6.2'	=> 'Windows 8',
17
+	'windows nt 6.1'	=> 'Windows 7',
18
+	'windows nt 6.0'	=> 'Windows Vista',
19
+	'windows nt 5.2'	=> 'Windows 2003',
20
+	'windows nt 5.1'	=> 'Windows XP',
21
+	'windows nt 5.0'	=> 'Windows 2000',
22
+	'windows nt 4.0'	=> 'Windows NT 4.0',
23
+	'winnt4.0'			=> 'Windows NT 4.0',
24
+	'winnt 4.0'			=> 'Windows NT',
25
+	'winnt'				=> 'Windows NT',
26
+	'windows 98'		=> 'Windows 98',
27
+	'win98'				=> 'Windows 98',
28
+	'windows 95'		=> 'Windows 95',
29
+	'win95'				=> 'Windows 95',
30
+	'windows phone'			=> 'Windows Phone',
31
+	'windows'			=> 'Unknown Windows OS',
32
+	'android'			=> 'Android',
33
+	'blackberry'		=> 'BlackBerry',
34
+	'iphone'			=> 'iOS',
35
+	'ipad'				=> 'iOS',
36
+	'ipod'				=> 'iOS',
37
+	'os x'				=> 'Mac OS X',
38
+	'ppc mac'			=> 'Power PC Mac',
39
+	'freebsd'			=> 'FreeBSD',
40
+	'ppc'				=> 'Macintosh',
41
+	'linux'				=> 'Linux',
42
+	'debian'			=> 'Debian',
43
+	'sunos'				=> 'Sun Solaris',
44
+	'beos'				=> 'BeOS',
45
+	'apachebench'		=> 'ApacheBench',
46
+	'aix'				=> 'AIX',
47
+	'irix'				=> 'Irix',
48
+	'osf'				=> 'DEC OSF',
49
+	'hp-ux'				=> 'HP-UX',
50
+	'netbsd'			=> 'NetBSD',
51
+	'bsdi'				=> 'BSDi',
52
+	'openbsd'			=> 'OpenBSD',
53
+	'gnu'				=> 'GNU/Linux',
54
+	'unix'				=> 'Unknown Unix OS',
55
+	'symbian' 			=> 'Symbian OS'
56
+);
57
+
58
+
59
+// The order of this array should NOT be changed. Many browsers return
60
+// multiple browser types so we want to identify the sub-type first.
61
+$browsers = array(
62
+	'OPR'			=> 'Opera',
63
+	'Flock'			=> 'Flock',
64
+	'Edge'			=> 'Edge',
65
+	'Chrome'		=> 'Chrome',
66
+	// Opera 10+ always reports Opera/9.80 and appends Version/<real version> to the user agent string
67
+	'Opera.*?Version'	=> 'Opera',
68
+	'Opera'			=> 'Opera',
69
+	'MSIE'			=> 'Internet Explorer',
70
+	'Internet Explorer'	=> 'Internet Explorer',
71
+	'Trident.* rv'	=> 'Internet Explorer',
72
+	'Shiira'		=> 'Shiira',
73
+	'Firefox'		=> 'Firefox',
74
+	'Chimera'		=> 'Chimera',
75
+	'Phoenix'		=> 'Phoenix',
76
+	'Firebird'		=> 'Firebird',
77
+	'Camino'		=> 'Camino',
78
+	'Netscape'		=> 'Netscape',
79
+	'OmniWeb'		=> 'OmniWeb',
80
+	'Safari'		=> 'Safari',
81
+	'Mozilla'		=> 'Mozilla',
82
+	'Konqueror'		=> 'Konqueror',
83
+	'icab'			=> 'iCab',
84
+	'Lynx'			=> 'Lynx',
85
+	'Links'			=> 'Links',
86
+	'hotjava'		=> 'HotJava',
87
+	'amaya'			=> 'Amaya',
88
+	'IBrowse'		=> 'IBrowse',
89
+	'Maxthon'		=> 'Maxthon',
90
+	'Ubuntu'		=> 'Ubuntu Web Browser'
91
+);
92
+
93
+$mobiles = array(
94
+	// legacy array, old values commented out
95
+	'mobileexplorer'	=> 'Mobile Explorer',
96
+//  'openwave'			=> 'Open Wave',
97
+//	'opera mini'		=> 'Opera Mini',
98
+//	'operamini'			=> 'Opera Mini',
99
+//	'elaine'			=> 'Palm',
100
+	'palmsource'		=> 'Palm',
101
+//	'digital paths'		=> 'Palm',
102
+//	'avantgo'			=> 'Avantgo',
103
+//	'xiino'				=> 'Xiino',
104
+	'palmscape'			=> 'Palmscape',
105
+//	'nokia'				=> 'Nokia',
106
+//	'ericsson'			=> 'Ericsson',
107
+//	'blackberry'		=> 'BlackBerry',
108
+//	'motorola'			=> 'Motorola'
109
+
110
+	// Phones and Manufacturers
111
+	'motorola'		=> 'Motorola',
112
+	'nokia'			=> 'Nokia',
113
+	'nexus'			=> 'Nexus',
114
+	'palm'			=> 'Palm',
115
+	'iphone'		=> 'Apple iPhone',
116
+	'ipad'			=> 'iPad',
117
+	'ipod'			=> 'Apple iPod Touch',
118
+	'sony'			=> 'Sony Ericsson',
119
+	'ericsson'		=> 'Sony Ericsson',
120
+	'blackberry'	=> 'BlackBerry',
121
+	'cocoon'		=> 'O2 Cocoon',
122
+	'blazer'		=> 'Treo',
123
+	'lg'			=> 'LG',
124
+	'amoi'			=> 'Amoi',
125
+	'xda'			=> 'XDA',
126
+	'mda'			=> 'MDA',
127
+	'vario'			=> 'Vario',
128
+	'htc'			=> 'HTC',
129
+	'samsung'		=> 'Samsung',
130
+	'sharp'			=> 'Sharp',
131
+	'sie-'			=> 'Siemens',
132
+	'alcatel'		=> 'Alcatel',
133
+	'benq'			=> 'BenQ',
134
+	'ipaq'			=> 'HP iPaq',
135
+	'mot-'			=> 'Motorola',
136
+	'playstation portable'	=> 'PlayStation Portable',
137
+	'playstation 3'		=> 'PlayStation 3',
138
+	'playstation vita'  	=> 'PlayStation Vita',
139
+	'hiptop'		=> 'Danger Hiptop',
140
+	'nec-'			=> 'NEC',
141
+	'panasonic'		=> 'Panasonic',
142
+	'philips'		=> 'Philips',
143
+	'sagem'			=> 'Sagem',
144
+	'sanyo'			=> 'Sanyo',
145
+	'spv'			=> 'SPV',
146
+	'zte'			=> 'ZTE',
147
+	'sendo'			=> 'Sendo',
148
+	'nintendo dsi'	=> 'Nintendo DSi',
149
+	'nintendo ds'	=> 'Nintendo DS',
150
+	'nintendo 3ds'	=> 'Nintendo 3DS',
151
+	'wii'			=> 'Nintendo Wii',
152
+	'open web'		=> 'Open Web',
153
+	'openweb'		=> 'OpenWeb',
154
+	'meizu'                 => 'Meizu',
155
+
156
+	// Operating Systems
157
+	'android'		=> 'Android',
158
+	'symbian'		=> 'Symbian',
159
+	'SymbianOS'		=> 'SymbianOS',
160
+	'elaine'		=> 'Palm',
161
+	'series60'		=> 'Symbian S60',
162
+	'windows ce'	=> 'Windows CE',
163
+
164
+	// Browsers
165
+	'obigo'			=> 'Obigo',
166
+	'netfront'		=> 'Netfront Browser',
167
+	'openwave'		=> 'Openwave Browser',
168
+	'mobilexplorer'	=> 'Mobile Explorer',
169
+	'operamini'		=> 'Opera Mini',
170
+	'opera mini'	=> 'Opera Mini',
171
+	'opera mobi'	=> 'Opera Mobile',
172
+	'fennec'		=> 'Firefox Mobile',
173
+
174
+	// Other
175
+	'digital paths'	=> 'Digital Paths',
176
+	'avantgo'		=> 'AvantGo',
177
+	'xiino'			=> 'Xiino',
178
+	'novarra'		=> 'Novarra Transcoder',
179
+	'vodafone'		=> 'Vodafone',
180
+	'docomo'		=> 'NTT DoCoMo',
181
+	'o2'			=> 'O2',
182
+
183
+	// Fallback
184
+	'mobile'		=> 'Generic Mobile',
185
+	'wireless'		=> 'Generic Mobile',
186
+	'j2me'			=> 'Generic Mobile',
187
+	'midp'			=> 'Generic Mobile',
188
+	'cldc'			=> 'Generic Mobile',
189
+	'up.link'		=> 'Generic Mobile',
190
+	'up.browser'	=> 'Generic Mobile',
191
+	'smartphone'	=> 'Generic Mobile',
192
+	'cellphone'		=> 'Generic Mobile'
193
+);
194
+
195
+// There are hundreds of bots but these are the most common.
196
+$robots = array(
197
+	'googlebot'		=> 'Googlebot',
198
+	'msnbot'		=> 'MSNBot',
199
+	'baiduspider'		=> 'Baiduspider',
200
+	'bingbot'		=> 'Bing',
201
+	'slurp'			=> 'Inktomi Slurp',
202
+	'yahoo'			=> 'Yahoo',
203
+	'ask jeeves'		=> 'Ask Jeeves',
204
+	'fastcrawler'		=> 'FastCrawler',
205
+	'infoseek'		=> 'InfoSeek Robot 1.0',
206
+	'lycos'			=> 'Lycos',
207
+	'yandex'		=> 'YandexBot',
208
+	'mediapartners-google'	=> 'MediaPartners Google',
209
+	'CRAZYWEBCRAWLER'	=> 'Crazy Webcrawler',
210
+	'adsbot-google'		=> 'AdsBot Google',
211
+	'feedfetcher-google'	=> 'Feedfetcher Google',
212
+	'curious george'	=> 'Curious George',
213
+	'ia_archiver'		=> 'Alexa Crawler',
214
+	'MJ12bot'		=> 'Majestic-12',
215
+	'Uptimebot'		=> 'Uptimebot'
216
+);

+ 25 - 0
application/controllers/Welcome.php Datei anzeigen

@@ -0,0 +1,25 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+class Welcome extends CI_Controller {
5
+
6
+	/**
7
+	 * Index Page for this controller.
8
+	 *
9
+	 * Maps to the following URL
10
+	 * 		http://example.com/index.php/welcome
11
+	 *	- or -
12
+	 * 		http://example.com/index.php/welcome/index
13
+	 *	- or -
14
+	 * Since this controller is set as the default controller in
15
+	 * config/routes.php, it's displayed at http://example.com/
16
+	 *
17
+	 * So any other public methods not prefixed with an underscore will
18
+	 * map to /index.php/welcome/<method_name>
19
+	 * @see https://codeigniter.com/user_guide/general/urls.html
20
+	 */
21
+	public function index()
22
+	{
23
+		$this->load->view('welcome_message');
24
+	}
25
+}

+ 11 - 0
application/controllers/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
application/core/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
application/helpers/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
application/hooks/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
application/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
application/language/english/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
application/language/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
application/libraries/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
application/logs/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
application/models/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
application/third_party/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 8 - 0
application/views/errors/cli/error_404.php Datei anzeigen

@@ -0,0 +1,8 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+echo "\nERROR: ",
5
+	$heading,
6
+	"\n\n",
7
+	$message,
8
+	"\n\n";

+ 8 - 0
application/views/errors/cli/error_db.php Datei anzeigen

@@ -0,0 +1,8 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+echo "\nDatabase error: ",
5
+	$heading,
6
+	"\n\n",
7
+	$message,
8
+	"\n\n";

+ 21 - 0
application/views/errors/cli/error_exception.php Datei anzeigen

@@ -0,0 +1,21 @@
1
+<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
2
+
3
+An uncaught Exception was encountered
4
+
5
+Type:        <?php echo get_class($exception), "\n"; ?>
6
+Message:     <?php echo $message, "\n"; ?>
7
+Filename:    <?php echo $exception->getFile(), "\n"; ?>
8
+Line Number: <?php echo $exception->getLine(); ?>
9
+
10
+<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === TRUE): ?>
11
+
12
+Backtrace:
13
+<?php	foreach ($exception->getTrace() as $error): ?>
14
+<?php		if (isset($error['file']) && strpos($error['file'], realpath(BASEPATH)) !== 0): ?>
15
+	File: <?php echo $error['file'], "\n"; ?>
16
+	Line: <?php echo $error['line'], "\n"; ?>
17
+	Function: <?php echo $error['function'], "\n\n"; ?>
18
+<?php		endif ?>
19
+<?php	endforeach ?>
20
+
21
+<?php endif ?>

+ 8 - 0
application/views/errors/cli/error_general.php Datei anzeigen

@@ -0,0 +1,8 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+
4
+echo "\nERROR: ",
5
+	$heading,
6
+	"\n\n",
7
+	$message,
8
+	"\n\n";

+ 21 - 0
application/views/errors/cli/error_php.php Datei anzeigen

@@ -0,0 +1,21 @@
1
+<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>
2
+
3
+A PHP Error was encountered
4
+
5
+Severity:    <?php echo $severity, "\n"; ?>
6
+Message:     <?php echo $message, "\n"; ?>
7
+Filename:    <?php echo $filepath, "\n"; ?>
8
+Line Number: <?php echo $line; ?>
9
+
10
+<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === TRUE): ?>
11
+
12
+Backtrace:
13
+<?php	foreach (debug_backtrace() as $error): ?>
14
+<?php		if (isset($error['file']) && strpos($error['file'], realpath(BASEPATH)) !== 0): ?>
15
+	File: <?php echo $error['file'], "\n"; ?>
16
+	Line: <?php echo $error['line'], "\n"; ?>
17
+	Function: <?php echo $error['function'], "\n\n"; ?>
18
+<?php		endif ?>
19
+<?php	endforeach ?>
20
+
21
+<?php endif ?>

+ 11 - 0
application/views/errors/cli/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 64 - 0
application/views/errors/html/error_404.php Datei anzeigen

@@ -0,0 +1,64 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+?><!DOCTYPE html>
4
+<html lang="en">
5
+<head>
6
+<meta charset="utf-8">
7
+<title>404 Page Not Found</title>
8
+<style type="text/css">
9
+
10
+::selection { background-color: #E13300; color: white; }
11
+::-moz-selection { background-color: #E13300; color: white; }
12
+
13
+body {
14
+	background-color: #fff;
15
+	margin: 40px;
16
+	font: 13px/20px normal Helvetica, Arial, sans-serif;
17
+	color: #4F5155;
18
+}
19
+
20
+a {
21
+	color: #003399;
22
+	background-color: transparent;
23
+	font-weight: normal;
24
+}
25
+
26
+h1 {
27
+	color: #444;
28
+	background-color: transparent;
29
+	border-bottom: 1px solid #D0D0D0;
30
+	font-size: 19px;
31
+	font-weight: normal;
32
+	margin: 0 0 14px 0;
33
+	padding: 14px 15px 10px 15px;
34
+}
35
+
36
+code {
37
+	font-family: Consolas, Monaco, Courier New, Courier, monospace;
38
+	font-size: 12px;
39
+	background-color: #f9f9f9;
40
+	border: 1px solid #D0D0D0;
41
+	color: #002166;
42
+	display: block;
43
+	margin: 14px 0 14px 0;
44
+	padding: 12px 10px 12px 10px;
45
+}
46
+
47
+#container {
48
+	margin: 10px;
49
+	border: 1px solid #D0D0D0;
50
+	box-shadow: 0 0 8px #D0D0D0;
51
+}
52
+
53
+p {
54
+	margin: 12px 15px 12px 15px;
55
+}
56
+</style>
57
+</head>
58
+<body>
59
+	<div id="container">
60
+		<h1><?php echo $heading; ?></h1>
61
+		<?php echo $message; ?>
62
+	</div>
63
+</body>
64
+</html>

+ 64 - 0
application/views/errors/html/error_db.php Datei anzeigen

@@ -0,0 +1,64 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+?><!DOCTYPE html>
4
+<html lang="en">
5
+<head>
6
+<meta charset="utf-8">
7
+<title>Database Error</title>
8
+<style type="text/css">
9
+
10
+::selection { background-color: #E13300; color: white; }
11
+::-moz-selection { background-color: #E13300; color: white; }
12
+
13
+body {
14
+	background-color: #fff;
15
+	margin: 40px;
16
+	font: 13px/20px normal Helvetica, Arial, sans-serif;
17
+	color: #4F5155;
18
+}
19
+
20
+a {
21
+	color: #003399;
22
+	background-color: transparent;
23
+	font-weight: normal;
24
+}
25
+
26
+h1 {
27
+	color: #444;
28
+	background-color: transparent;
29
+	border-bottom: 1px solid #D0D0D0;
30
+	font-size: 19px;
31
+	font-weight: normal;
32
+	margin: 0 0 14px 0;
33
+	padding: 14px 15px 10px 15px;
34
+}
35
+
36
+code {
37
+	font-family: Consolas, Monaco, Courier New, Courier, monospace;
38
+	font-size: 12px;
39
+	background-color: #f9f9f9;
40
+	border: 1px solid #D0D0D0;
41
+	color: #002166;
42
+	display: block;
43
+	margin: 14px 0 14px 0;
44
+	padding: 12px 10px 12px 10px;
45
+}
46
+
47
+#container {
48
+	margin: 10px;
49
+	border: 1px solid #D0D0D0;
50
+	box-shadow: 0 0 8px #D0D0D0;
51
+}
52
+
53
+p {
54
+	margin: 12px 15px 12px 15px;
55
+}
56
+</style>
57
+</head>
58
+<body>
59
+	<div id="container">
60
+		<h1><?php echo $heading; ?></h1>
61
+		<?php echo $message; ?>
62
+	</div>
63
+</body>
64
+</html>

+ 32 - 0
application/views/errors/html/error_exception.php Datei anzeigen

@@ -0,0 +1,32 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+?>
4
+
5
+<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
6
+
7
+<h4>An uncaught Exception was encountered</h4>
8
+
9
+<p>Type: <?php echo get_class($exception); ?></p>
10
+<p>Message: <?php echo $message; ?></p>
11
+<p>Filename: <?php echo $exception->getFile(); ?></p>
12
+<p>Line Number: <?php echo $exception->getLine(); ?></p>
13
+
14
+<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === TRUE): ?>
15
+
16
+	<p>Backtrace:</p>
17
+	<?php foreach ($exception->getTrace() as $error): ?>
18
+
19
+		<?php if (isset($error['file']) && strpos($error['file'], realpath(BASEPATH)) !== 0): ?>
20
+
21
+			<p style="margin-left:10px">
22
+			File: <?php echo $error['file']; ?><br />
23
+			Line: <?php echo $error['line']; ?><br />
24
+			Function: <?php echo $error['function']; ?>
25
+			</p>
26
+		<?php endif ?>
27
+
28
+	<?php endforeach ?>
29
+
30
+<?php endif ?>
31
+
32
+</div>

+ 64 - 0
application/views/errors/html/error_general.php Datei anzeigen

@@ -0,0 +1,64 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+?><!DOCTYPE html>
4
+<html lang="en">
5
+<head>
6
+<meta charset="utf-8">
7
+<title>Error</title>
8
+<style type="text/css">
9
+
10
+::selection { background-color: #E13300; color: white; }
11
+::-moz-selection { background-color: #E13300; color: white; }
12
+
13
+body {
14
+	background-color: #fff;
15
+	margin: 40px;
16
+	font: 13px/20px normal Helvetica, Arial, sans-serif;
17
+	color: #4F5155;
18
+}
19
+
20
+a {
21
+	color: #003399;
22
+	background-color: transparent;
23
+	font-weight: normal;
24
+}
25
+
26
+h1 {
27
+	color: #444;
28
+	background-color: transparent;
29
+	border-bottom: 1px solid #D0D0D0;
30
+	font-size: 19px;
31
+	font-weight: normal;
32
+	margin: 0 0 14px 0;
33
+	padding: 14px 15px 10px 15px;
34
+}
35
+
36
+code {
37
+	font-family: Consolas, Monaco, Courier New, Courier, monospace;
38
+	font-size: 12px;
39
+	background-color: #f9f9f9;
40
+	border: 1px solid #D0D0D0;
41
+	color: #002166;
42
+	display: block;
43
+	margin: 14px 0 14px 0;
44
+	padding: 12px 10px 12px 10px;
45
+}
46
+
47
+#container {
48
+	margin: 10px;
49
+	border: 1px solid #D0D0D0;
50
+	box-shadow: 0 0 8px #D0D0D0;
51
+}
52
+
53
+p {
54
+	margin: 12px 15px 12px 15px;
55
+}
56
+</style>
57
+</head>
58
+<body>
59
+	<div id="container">
60
+		<h1><?php echo $heading; ?></h1>
61
+		<?php echo $message; ?>
62
+	</div>
63
+</body>
64
+</html>

+ 33 - 0
application/views/errors/html/error_php.php Datei anzeigen

@@ -0,0 +1,33 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+?>
4
+
5
+<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
6
+
7
+<h4>A PHP Error was encountered</h4>
8
+
9
+<p>Severity: <?php echo $severity; ?></p>
10
+<p>Message:  <?php echo $message; ?></p>
11
+<p>Filename: <?php echo $filepath; ?></p>
12
+<p>Line Number: <?php echo $line; ?></p>
13
+
14
+<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === TRUE): ?>
15
+
16
+	<p>Backtrace:</p>
17
+	<?php foreach (debug_backtrace() as $error): ?>
18
+
19
+		<?php if (isset($error['file']) && strpos($error['file'], realpath(BASEPATH)) !== 0): ?>
20
+
21
+			<p style="margin-left:10px">
22
+			File: <?php echo $error['file'] ?><br />
23
+			Line: <?php echo $error['line'] ?><br />
24
+			Function: <?php echo $error['function'] ?>
25
+			</p>
26
+
27
+		<?php endif ?>
28
+
29
+	<?php endforeach ?>
30
+
31
+<?php endif ?>
32
+
33
+</div>

+ 11 - 0
application/views/errors/html/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
application/views/errors/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
application/views/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 89 - 0
application/views/welcome_message.php Datei anzeigen

@@ -0,0 +1,89 @@
1
+<?php
2
+defined('BASEPATH') OR exit('No direct script access allowed');
3
+?><!DOCTYPE html>
4
+<html lang="en">
5
+<head>
6
+	<meta charset="utf-8">
7
+	<title>Welcome to CodeIgniter</title>
8
+
9
+	<style type="text/css">
10
+
11
+	::selection { background-color: #E13300; color: white; }
12
+	::-moz-selection { background-color: #E13300; color: white; }
13
+
14
+	body {
15
+		background-color: #fff;
16
+		margin: 40px;
17
+		font: 13px/20px normal Helvetica, Arial, sans-serif;
18
+		color: #4F5155;
19
+	}
20
+
21
+	a {
22
+		color: #003399;
23
+		background-color: transparent;
24
+		font-weight: normal;
25
+	}
26
+
27
+	h1 {
28
+		color: #444;
29
+		background-color: transparent;
30
+		border-bottom: 1px solid #D0D0D0;
31
+		font-size: 19px;
32
+		font-weight: normal;
33
+		margin: 0 0 14px 0;
34
+		padding: 14px 15px 10px 15px;
35
+	}
36
+
37
+	code {
38
+		font-family: Consolas, Monaco, Courier New, Courier, monospace;
39
+		font-size: 12px;
40
+		background-color: #f9f9f9;
41
+		border: 1px solid #D0D0D0;
42
+		color: #002166;
43
+		display: block;
44
+		margin: 14px 0 14px 0;
45
+		padding: 12px 10px 12px 10px;
46
+	}
47
+
48
+	#body {
49
+		margin: 0 15px 0 15px;
50
+	}
51
+
52
+	p.footer {
53
+		text-align: right;
54
+		font-size: 11px;
55
+		border-top: 1px solid #D0D0D0;
56
+		line-height: 32px;
57
+		padding: 0 10px 0 10px;
58
+		margin: 20px 0 0 0;
59
+	}
60
+
61
+	#container {
62
+		margin: 10px;
63
+		border: 1px solid #D0D0D0;
64
+		box-shadow: 0 0 8px #D0D0D0;
65
+	}
66
+	</style>
67
+</head>
68
+<body>
69
+
70
+<div id="container">
71
+	<h1>Welcome to CodeIgniter!</h1>
72
+
73
+	<div id="body">
74
+		<p>The page you are looking at is being generated dynamically by CodeIgniter.</p>
75
+
76
+		<p>If you would like to edit this page you'll find it located at:</p>
77
+		<code>application/views/welcome_message.php</code>
78
+
79
+		<p>The corresponding controller for this page is found at:</p>
80
+		<code>application/controllers/Welcome.php</code>
81
+
82
+		<p>If you are exploring CodeIgniter for the very first time, you should start by reading the <a href="user_guide/">User Guide</a>.</p>
83
+	</div>
84
+
85
+	<p class="footer">Page rendered in <strong>{elapsed_time}</strong> seconds. <?php echo  (ENVIRONMENT === 'development') ?  'CodeIgniter Version <strong>' . CI_VERSION . '</strong>' : '' ?></p>
86
+</div>
87
+
88
+</body>
89
+</html>

+ 23 - 0
composer.json Datei anzeigen

@@ -0,0 +1,23 @@
1
+{
2
+	"description": "The CodeIgniter framework",
3
+	"name": "codeigniter/framework",
4
+	"type": "project",
5
+	"homepage": "https://codeigniter.com",
6
+	"license": "MIT",
7
+	"support": {
8
+		"forum": "http://forum.codeigniter.com/",
9
+		"wiki": "https://github.com/bcit-ci/CodeIgniter/wiki",
10
+		"slack": "https://codeigniterchat.slack.com",
11
+		"source": "https://github.com/bcit-ci/CodeIgniter"
12
+	},
13
+	"require": {
14
+		"php": ">=5.3.7"
15
+	},
16
+	"suggest": {
17
+		"paragonie/random_compat": "Provides better randomness in PHP 5.x"
18
+	},
19
+	"require-dev": {
20
+		"mikey179/vfsStream": "1.1.*",
21
+		"phpunit/phpunit": "4.* || 5.*"
22
+	}
23
+}

+ 93 - 0
contributing.md Datei anzeigen

@@ -0,0 +1,93 @@
1
+# Contributing to CodeIgniter
2
+
3
+CodeIgniter is a community driven project and accepts contributions of code and documentation from the community. These contributions are made in the form of Issues or [Pull Requests](http://help.github.com/send-pull-requests/) on the [CodeIgniter repository](https://github.com/bcit-ci/CodeIgniter) on GitHub.
4
+
5
+Issues are a quick way to point out a bug. If you find a bug or documentation error in CodeIgniter then please check a few things first:
6
+
7
+1. There is not already an open Issue
8
+2. The issue has already been fixed (check the develop branch, or look for closed Issues)
9
+3. Is it something really obvious that you can fix yourself?
10
+
11
+Reporting issues is helpful but an even better approach is to send a Pull Request, which is done by "Forking" the main repository and committing to your own copy. This will require you to use the version control system called Git.
12
+
13
+## Guidelines
14
+
15
+Before we look into how, here are the guidelines. If your Pull Requests fail
16
+to pass these guidelines it will be declined and you will need to re-submit
17
+when you’ve made the changes. This might sound a bit tough, but it is required
18
+for us to maintain quality of the code-base.
19
+
20
+### PHP Style
21
+
22
+All code must meet the [Style Guide](https://codeigniter.com/user_guide/general/styleguide.html), which is
23
+essentially the [Allman indent style](https://en.wikipedia.org/wiki/Indent_style#Allman_style), underscores and readable operators. This makes certain that all code is the same format as the existing code and means it will be as readable as possible.
24
+
25
+### Documentation
26
+
27
+If you change anything that requires a change to documentation then you will need to add it. New classes, methods, parameters, changing default values, etc are all things that will require a change to documentation. The change-log must also be updated for every change. Also PHPDoc blocks must be maintained.
28
+
29
+### Compatibility
30
+
31
+CodeIgniter recommends PHP 5.4 or newer to be used, but it should be
32
+compatible with PHP 5.2.4 so all code supplied must stick to this
33
+requirement. If PHP 5.3 (and above) functions or features are used then
34
+there must be a fallback for PHP 5.2.4.
35
+
36
+### Branching
37
+
38
+CodeIgniter uses the [Git-Flow](http://nvie.com/posts/a-successful-git-branching-model/) branching model which requires all pull requests to be sent to the "develop" branch. This is
39
+where the next planned version will be developed. The "master" branch will always contain the latest stable version and is kept clean so a "hotfix" (e.g: an emergency security patch) can be applied to master to create a new version, without worrying about other features holding it up. For this reason all commits need to be made to "develop" and any sent to "master" will be closed automatically. If you have multiple changes to submit, please place all changes into their own branch on your fork.
40
+
41
+One thing at a time: A pull request should only contain one change. That does not mean only one commit, but one change - however many commits it took. The reason for this is that if you change X and Y but send a pull request for both at the same time, we might really want X but disagree with Y, meaning we cannot merge the request. Using the Git-Flow branching model you can create new branches for both of these features and send two requests.
42
+
43
+### Signing
44
+
45
+You must sign your work, certifying that you either wrote the work or otherwise have the right to pass it on to an open source project. git makes this trivial as you merely have to use `--signoff` on your commits to your CodeIgniter fork.
46
+
47
+`git commit --signoff`
48
+
49
+or simply
50
+
51
+`git commit -s`
52
+
53
+This will sign your commits with the information setup in your git config, e.g.
54
+
55
+`Signed-off-by: John Q Public <john.public@example.com>`
56
+
57
+If you are using [Tower](http://www.git-tower.com/) there is a "Sign-Off" checkbox in the commit window. You could even alias git commit to use the `-s` flag so you don’t have to think about it.
58
+
59
+By signing your work in this manner, you certify to a "Developer's Certificate of Origin". The current version of this certificate is in the `DCO.txt` file in the root of this repository.
60
+
61
+## How-to Guide
62
+
63
+There are two ways to make changes, the easy way and the hard way. Either way you will need to [create a GitHub account](https://github.com/signup/free).
64
+
65
+Easy way GitHub allows in-line editing of files for making simple typo changes and quick-fixes. This is not the best way as you are unable to test the code works. If you do this you could be introducing syntax errors, etc, but for a Git-phobic user this is good for a quick-fix.
66
+
67
+Hard way The best way to contribute is to "clone" your fork of CodeIgniter to your development area. That sounds like some jargon, but "forking" on GitHub means "making a copy of that repo to your account" and "cloning" means "copying that code to your environment so you can work on it".
68
+
69
+1. [Set up Git](https://help.github.com/en/articles/set-up-git) (Windows, Mac & Linux)
70
+2. Go to the [CodeIgniter repo](https://github.com/bcit-ci/CodeIgniter)
71
+3. [Fork it](https://help.github.com/en/articles/fork-a-repo)
72
+4. [Clone](https://help.github.com/en/articles/fetching-a-remote#clone) your forked CodeIgniter repo: git@github.com:<your-name>/CodeIgniter.git.
73
+5. Checkout the "develop" branch. At this point you are ready to start making changes.
74
+6. Fix existing bugs on the Issue tracker after taking a look to see nobody else is working on them.
75
+7. [Commit](https://help.github.com/en/articles/adding-a-file-to-a-repository-using-the-command-line) the files
76
+8. [Push](https://help.github.com/en/articles/pushing-to-a-remote) your develop branch to your fork
77
+9. [Send a pull request](https://help.github.com/en/articles/creating-a-pull-request)
78
+
79
+The Reactor Engineers will now be alerted about the change and at least one of the team will respond. If your change fails to meet the guidelines it will be bounced, or feedback will be provided to help you improve it.
80
+
81
+Once the Reactor Engineer handling your pull request is happy with it they will merge it into develop and your patch will be part of the next release.
82
+
83
+### Keeping your fork up-to-date
84
+
85
+Unlike systems like Subversion, Git can have multiple remotes. A remote is the name for a URL of a Git repository. By default your fork will have a remote named "origin" which points to your fork, but you can add another remote named "codeigniter" which points to `git://github.com/bcit-ci/CodeIgniter.git`. This is a read-only remote but you can pull from this develop branch to update your own.
86
+
87
+If you are using command-line you can do the following:
88
+
89
+1. `git remote add codeigniter git://github.com/bcit-ci/CodeIgniter.git`
90
+2. `git pull codeigniter develop`
91
+3. `git push origin develop`
92
+
93
+Now your fork is up to date. This should be done regularly, or before you send a pull request at least.

+ 315 - 0
index.php Datei anzeigen

@@ -0,0 +1,315 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+
39
+/*
40
+ *---------------------------------------------------------------
41
+ * APPLICATION ENVIRONMENT
42
+ *---------------------------------------------------------------
43
+ *
44
+ * You can load different configurations depending on your
45
+ * current environment. Setting the environment also influences
46
+ * things like logging and error reporting.
47
+ *
48
+ * This can be set to anything, but default usage is:
49
+ *
50
+ *     development
51
+ *     testing
52
+ *     production
53
+ *
54
+ * NOTE: If you change these, also change the error_reporting() code below
55
+ */
56
+	define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
57
+
58
+/*
59
+ *---------------------------------------------------------------
60
+ * ERROR REPORTING
61
+ *---------------------------------------------------------------
62
+ *
63
+ * Different environments will require different levels of error reporting.
64
+ * By default development will show errors but testing and live will hide them.
65
+ */
66
+switch (ENVIRONMENT)
67
+{
68
+	case 'development':
69
+		error_reporting(-1);
70
+		ini_set('display_errors', 1);
71
+	break;
72
+
73
+	case 'testing':
74
+	case 'production':
75
+		ini_set('display_errors', 0);
76
+		if (version_compare(PHP_VERSION, '5.3', '>='))
77
+		{
78
+			error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
79
+		}
80
+		else
81
+		{
82
+			error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
83
+		}
84
+	break;
85
+
86
+	default:
87
+		header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
88
+		echo 'The application environment is not set correctly.';
89
+		exit(1); // EXIT_ERROR
90
+}
91
+
92
+/*
93
+ *---------------------------------------------------------------
94
+ * SYSTEM DIRECTORY NAME
95
+ *---------------------------------------------------------------
96
+ *
97
+ * This variable must contain the name of your "system" directory.
98
+ * Set the path if it is not in the same directory as this file.
99
+ */
100
+	$system_path = 'system';
101
+
102
+/*
103
+ *---------------------------------------------------------------
104
+ * APPLICATION DIRECTORY NAME
105
+ *---------------------------------------------------------------
106
+ *
107
+ * If you want this front controller to use a different "application"
108
+ * directory than the default one you can set its name here. The directory
109
+ * can also be renamed or relocated anywhere on your server. If you do,
110
+ * use an absolute (full) server path.
111
+ * For more info please see the user guide:
112
+ *
113
+ * https://codeigniter.com/user_guide/general/managing_apps.html
114
+ *
115
+ * NO TRAILING SLASH!
116
+ */
117
+	$application_folder = 'application';
118
+
119
+/*
120
+ *---------------------------------------------------------------
121
+ * VIEW DIRECTORY NAME
122
+ *---------------------------------------------------------------
123
+ *
124
+ * If you want to move the view directory out of the application
125
+ * directory, set the path to it here. The directory can be renamed
126
+ * and relocated anywhere on your server. If blank, it will default
127
+ * to the standard location inside your application directory.
128
+ * If you do move this, use an absolute (full) server path.
129
+ *
130
+ * NO TRAILING SLASH!
131
+ */
132
+	$view_folder = '';
133
+
134
+
135
+/*
136
+ * --------------------------------------------------------------------
137
+ * DEFAULT CONTROLLER
138
+ * --------------------------------------------------------------------
139
+ *
140
+ * Normally you will set your default controller in the routes.php file.
141
+ * You can, however, force a custom routing by hard-coding a
142
+ * specific controller class/function here. For most applications, you
143
+ * WILL NOT set your routing here, but it's an option for those
144
+ * special instances where you might want to override the standard
145
+ * routing in a specific front controller that shares a common CI installation.
146
+ *
147
+ * IMPORTANT: If you set the routing here, NO OTHER controller will be
148
+ * callable. In essence, this preference limits your application to ONE
149
+ * specific controller. Leave the function name blank if you need
150
+ * to call functions dynamically via the URI.
151
+ *
152
+ * Un-comment the $routing array below to use this feature
153
+ */
154
+	// The directory name, relative to the "controllers" directory.  Leave blank
155
+	// if your controller is not in a sub-directory within the "controllers" one
156
+	// $routing['directory'] = '';
157
+
158
+	// The controller class file name.  Example:  mycontroller
159
+	// $routing['controller'] = '';
160
+
161
+	// The controller function you wish to be called.
162
+	// $routing['function']	= '';
163
+
164
+
165
+/*
166
+ * -------------------------------------------------------------------
167
+ *  CUSTOM CONFIG VALUES
168
+ * -------------------------------------------------------------------
169
+ *
170
+ * The $assign_to_config array below will be passed dynamically to the
171
+ * config class when initialized. This allows you to set custom config
172
+ * items or override any default config values found in the config.php file.
173
+ * This can be handy as it permits you to share one application between
174
+ * multiple front controller files, with each file containing different
175
+ * config values.
176
+ *
177
+ * Un-comment the $assign_to_config array below to use this feature
178
+ */
179
+	// $assign_to_config['name_of_config_item'] = 'value of config item';
180
+
181
+
182
+
183
+// --------------------------------------------------------------------
184
+// END OF USER CONFIGURABLE SETTINGS.  DO NOT EDIT BELOW THIS LINE
185
+// --------------------------------------------------------------------
186
+
187
+/*
188
+ * ---------------------------------------------------------------
189
+ *  Resolve the system path for increased reliability
190
+ * ---------------------------------------------------------------
191
+ */
192
+
193
+	// Set the current directory correctly for CLI requests
194
+	if (defined('STDIN'))
195
+	{
196
+		chdir(dirname(__FILE__));
197
+	}
198
+
199
+	if (($_temp = realpath($system_path)) !== FALSE)
200
+	{
201
+		$system_path = $_temp.DIRECTORY_SEPARATOR;
202
+	}
203
+	else
204
+	{
205
+		// Ensure there's a trailing slash
206
+		$system_path = strtr(
207
+			rtrim($system_path, '/\\'),
208
+			'/\\',
209
+			DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
210
+		).DIRECTORY_SEPARATOR;
211
+	}
212
+
213
+	// Is the system path correct?
214
+	if ( ! is_dir($system_path))
215
+	{
216
+		header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
217
+		echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME);
218
+		exit(3); // EXIT_CONFIG
219
+	}
220
+
221
+/*
222
+ * -------------------------------------------------------------------
223
+ *  Now that we know the path, set the main path constants
224
+ * -------------------------------------------------------------------
225
+ */
226
+	// The name of THIS file
227
+	define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
228
+
229
+	// Path to the system directory
230
+	define('BASEPATH', $system_path);
231
+
232
+	// Path to the front controller (this file) directory
233
+	define('FCPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
234
+
235
+	// Name of the "system" directory
236
+	define('SYSDIR', basename(BASEPATH));
237
+
238
+	// The path to the "application" directory
239
+	if (is_dir($application_folder))
240
+	{
241
+		if (($_temp = realpath($application_folder)) !== FALSE)
242
+		{
243
+			$application_folder = $_temp;
244
+		}
245
+		else
246
+		{
247
+			$application_folder = strtr(
248
+				rtrim($application_folder, '/\\'),
249
+				'/\\',
250
+				DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
251
+			);
252
+		}
253
+	}
254
+	elseif (is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
255
+	{
256
+		$application_folder = BASEPATH.strtr(
257
+			trim($application_folder, '/\\'),
258
+			'/\\',
259
+			DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
260
+		);
261
+	}
262
+	else
263
+	{
264
+		header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
265
+		echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
266
+		exit(3); // EXIT_CONFIG
267
+	}
268
+
269
+	define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
270
+
271
+	// The path to the "views" directory
272
+	if ( ! isset($view_folder[0]) && is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
273
+	{
274
+		$view_folder = APPPATH.'views';
275
+	}
276
+	elseif (is_dir($view_folder))
277
+	{
278
+		if (($_temp = realpath($view_folder)) !== FALSE)
279
+		{
280
+			$view_folder = $_temp;
281
+		}
282
+		else
283
+		{
284
+			$view_folder = strtr(
285
+				rtrim($view_folder, '/\\'),
286
+				'/\\',
287
+				DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
288
+			);
289
+		}
290
+	}
291
+	elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
292
+	{
293
+		$view_folder = APPPATH.strtr(
294
+			trim($view_folder, '/\\'),
295
+			'/\\',
296
+			DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
297
+		);
298
+	}
299
+	else
300
+	{
301
+		header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
302
+		echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
303
+		exit(3); // EXIT_CONFIG
304
+	}
305
+
306
+	define('VIEWPATH', $view_folder.DIRECTORY_SEPARATOR);
307
+
308
+/*
309
+ * --------------------------------------------------------------------
310
+ * LOAD THE BOOTSTRAP FILE
311
+ * --------------------------------------------------------------------
312
+ *
313
+ * And away we go...
314
+ */
315
+require_once BASEPATH.'core/CodeIgniter.php';

+ 21 - 0
license.txt Datei anzeigen

@@ -0,0 +1,21 @@
1
+The MIT License (MIT)
2
+
3
+Copyright (c) 2014 - 2019, British Columbia Institute of Technology
4
+
5
+Permission is hereby granted, free of charge, to any person obtaining a copy
6
+of this software and associated documentation files (the "Software"), to deal
7
+in the Software without restriction, including without limitation the rights
8
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+copies of the Software, and to permit persons to whom the Software is
10
+furnished to do so, subject to the following conditions:
11
+
12
+The above copyright notice and this permission notice shall be included in
13
+all copies or substantial portions of the Software.
14
+
15
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+THE SOFTWARE.

+ 70 - 0
readme.rst Datei anzeigen

@@ -0,0 +1,70 @@
1
+###################
2
+What is CodeIgniter
3
+###################
4
+
5
+CodeIgniter is an Application Development Framework - a toolkit - for people
6
+who build web sites using PHP. Its goal is to enable you to develop projects
7
+much faster than you could if you were writing code from scratch, by providing
8
+a rich set of libraries for commonly needed tasks, as well as a simple
9
+interface and logical structure to access these libraries. CodeIgniter lets
10
+you creatively focus on your project by minimizing the amount of code needed
11
+for a given task.
12
+
13
+*******************
14
+Release Information
15
+*******************
16
+
17
+This repo contains in-development code for future releases. To download the
18
+latest stable release please visit the `CodeIgniter Downloads
19
+<https://codeigniter.com/download>`_ page.
20
+
21
+**************************
22
+Changelog and New Features
23
+**************************
24
+
25
+You can find a list of all changes for each release in the `user
26
+guide change log <https://github.com/bcit-ci/CodeIgniter/blob/develop/user_guide_src/source/changelog.rst>`_.
27
+
28
+*******************
29
+Server Requirements
30
+*******************
31
+
32
+PHP version 5.6 or newer is recommended.
33
+
34
+It should work on 5.3.7 as well, but we strongly advise you NOT to run
35
+such old versions of PHP, because of potential security and performance
36
+issues, as well as missing features.
37
+
38
+************
39
+Installation
40
+************
41
+
42
+Please see the `installation section <https://codeigniter.com/user_guide/installation/index.html>`_
43
+of the CodeIgniter User Guide.
44
+
45
+*******
46
+License
47
+*******
48
+
49
+Please see the `license
50
+agreement <https://github.com/bcit-ci/CodeIgniter/blob/develop/user_guide_src/source/license.rst>`_.
51
+
52
+*********
53
+Resources
54
+*********
55
+
56
+-  `User Guide <https://codeigniter.com/docs>`_
57
+-  `Language File Translations <https://github.com/bcit-ci/codeigniter3-translations>`_
58
+-  `Community Forums <http://forum.codeigniter.com/>`_
59
+-  `Community Wiki <https://github.com/bcit-ci/CodeIgniter/wiki>`_
60
+-  `Community Slack Channel <https://codeigniterchat.slack.com>`_
61
+
62
+Report security issues to our `Security Panel <mailto:security@codeigniter.com>`_
63
+or via our `page on HackerOne <https://hackerone.com/codeigniter>`_, thank you.
64
+
65
+***************
66
+Acknowledgement
67
+***************
68
+
69
+The CodeIgniter team would like to thank EllisLab, all the
70
+contributors to the CodeIgniter project and you, the CodeIgniter user.

+ 6 - 0
system/.htaccess Datei anzeigen

@@ -0,0 +1,6 @@
1
+<IfModule authz_core_module>
2
+	Require all denied
3
+</IfModule>
4
+<IfModule !authz_core_module>
5
+	Deny from all
6
+</IfModule>

+ 133 - 0
system/core/Benchmark.php Datei anzeigen

@@ -0,0 +1,133 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Benchmark Class
42
+ *
43
+ * This class enables you to mark points and calculate the time difference
44
+ * between them. Memory consumption can also be displayed.
45
+ *
46
+ * @package		CodeIgniter
47
+ * @subpackage	Libraries
48
+ * @category	Libraries
49
+ * @author		EllisLab Dev Team
50
+ * @link		https://codeigniter.com/user_guide/libraries/benchmark.html
51
+ */
52
+class CI_Benchmark {
53
+
54
+	/**
55
+	 * List of all benchmark markers
56
+	 *
57
+	 * @var	array
58
+	 */
59
+	public $marker = array();
60
+
61
+	/**
62
+	 * Set a benchmark marker
63
+	 *
64
+	 * Multiple calls to this function can be made so that several
65
+	 * execution points can be timed.
66
+	 *
67
+	 * @param	string	$name	Marker name
68
+	 * @return	void
69
+	 */
70
+	public function mark($name)
71
+	{
72
+		$this->marker[$name] = microtime(TRUE);
73
+	}
74
+
75
+	// --------------------------------------------------------------------
76
+
77
+	/**
78
+	 * Elapsed time
79
+	 *
80
+	 * Calculates the time difference between two marked points.
81
+	 *
82
+	 * If the first parameter is empty this function instead returns the
83
+	 * {elapsed_time} pseudo-variable. This permits the full system
84
+	 * execution time to be shown in a template. The output class will
85
+	 * swap the real value for this variable.
86
+	 *
87
+	 * @param	string	$point1		A particular marked point
88
+	 * @param	string	$point2		A particular marked point
89
+	 * @param	int	$decimals	Number of decimal places
90
+	 *
91
+	 * @return	string	Calculated elapsed time on success,
92
+	 *			an '{elapsed_string}' if $point1 is empty
93
+	 *			or an empty string if $point1 is not found.
94
+	 */
95
+	public function elapsed_time($point1 = '', $point2 = '', $decimals = 4)
96
+	{
97
+		if ($point1 === '')
98
+		{
99
+			return '{elapsed_time}';
100
+		}
101
+
102
+		if ( ! isset($this->marker[$point1]))
103
+		{
104
+			return '';
105
+		}
106
+
107
+		if ( ! isset($this->marker[$point2]))
108
+		{
109
+			$this->marker[$point2] = microtime(TRUE);
110
+		}
111
+
112
+		return number_format($this->marker[$point2] - $this->marker[$point1], $decimals);
113
+	}
114
+
115
+	// --------------------------------------------------------------------
116
+
117
+	/**
118
+	 * Memory Usage
119
+	 *
120
+	 * Simply returns the {memory_usage} marker.
121
+	 *
122
+	 * This permits it to be put it anywhere in a template
123
+	 * without the memory being calculated until the end.
124
+	 * The output class will swap the real value for this variable.
125
+	 *
126
+	 * @return	string	'{memory_usage}'
127
+	 */
128
+	public function memory_usage()
129
+	{
130
+		return '{memory_usage}';
131
+	}
132
+
133
+}

+ 559 - 0
system/core/CodeIgniter.php Datei anzeigen

@@ -0,0 +1,559 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * System Initialization File
42
+ *
43
+ * Loads the base classes and executes the request.
44
+ *
45
+ * @package		CodeIgniter
46
+ * @subpackage	CodeIgniter
47
+ * @category	Front-controller
48
+ * @author		EllisLab Dev Team
49
+ * @link		https://codeigniter.com/user_guide/
50
+ */
51
+
52
+/**
53
+ * CodeIgniter Version
54
+ *
55
+ * @var	string
56
+ *
57
+ */
58
+	const CI_VERSION = '3.1.11';
59
+
60
+/*
61
+ * ------------------------------------------------------
62
+ *  Load the framework constants
63
+ * ------------------------------------------------------
64
+ */
65
+	if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
66
+	{
67
+		require_once(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
68
+	}
69
+
70
+	if (file_exists(APPPATH.'config/constants.php'))
71
+	{
72
+		require_once(APPPATH.'config/constants.php');
73
+	}
74
+
75
+/*
76
+ * ------------------------------------------------------
77
+ *  Load the global functions
78
+ * ------------------------------------------------------
79
+ */
80
+	require_once(BASEPATH.'core/Common.php');
81
+
82
+
83
+/*
84
+ * ------------------------------------------------------
85
+ * Security procedures
86
+ * ------------------------------------------------------
87
+ */
88
+
89
+if ( ! is_php('5.4'))
90
+{
91
+	ini_set('magic_quotes_runtime', 0);
92
+
93
+	if ((bool) ini_get('register_globals'))
94
+	{
95
+		$_protected = array(
96
+			'_SERVER',
97
+			'_GET',
98
+			'_POST',
99
+			'_FILES',
100
+			'_REQUEST',
101
+			'_SESSION',
102
+			'_ENV',
103
+			'_COOKIE',
104
+			'GLOBALS',
105
+			'HTTP_RAW_POST_DATA',
106
+			'system_path',
107
+			'application_folder',
108
+			'view_folder',
109
+			'_protected',
110
+			'_registered'
111
+		);
112
+
113
+		$_registered = ini_get('variables_order');
114
+		foreach (array('E' => '_ENV', 'G' => '_GET', 'P' => '_POST', 'C' => '_COOKIE', 'S' => '_SERVER') as $key => $superglobal)
115
+		{
116
+			if (strpos($_registered, $key) === FALSE)
117
+			{
118
+				continue;
119
+			}
120
+
121
+			foreach (array_keys($$superglobal) as $var)
122
+			{
123
+				if (isset($GLOBALS[$var]) && ! in_array($var, $_protected, TRUE))
124
+				{
125
+					$GLOBALS[$var] = NULL;
126
+				}
127
+			}
128
+		}
129
+	}
130
+}
131
+
132
+
133
+/*
134
+ * ------------------------------------------------------
135
+ *  Define a custom error handler so we can log PHP errors
136
+ * ------------------------------------------------------
137
+ */
138
+	set_error_handler('_error_handler');
139
+	set_exception_handler('_exception_handler');
140
+	register_shutdown_function('_shutdown_handler');
141
+
142
+/*
143
+ * ------------------------------------------------------
144
+ *  Set the subclass_prefix
145
+ * ------------------------------------------------------
146
+ *
147
+ * Normally the "subclass_prefix" is set in the config file.
148
+ * The subclass prefix allows CI to know if a core class is
149
+ * being extended via a library in the local application
150
+ * "libraries" folder. Since CI allows config items to be
151
+ * overridden via data set in the main index.php file,
152
+ * before proceeding we need to know if a subclass_prefix
153
+ * override exists. If so, we will set this value now,
154
+ * before any classes are loaded
155
+ * Note: Since the config file data is cached it doesn't
156
+ * hurt to load it here.
157
+ */
158
+	if ( ! empty($assign_to_config['subclass_prefix']))
159
+	{
160
+		get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
161
+	}
162
+
163
+/*
164
+ * ------------------------------------------------------
165
+ *  Should we use a Composer autoloader?
166
+ * ------------------------------------------------------
167
+ */
168
+	if ($composer_autoload = config_item('composer_autoload'))
169
+	{
170
+		if ($composer_autoload === TRUE)
171
+		{
172
+			file_exists(APPPATH.'vendor/autoload.php')
173
+				? require_once(APPPATH.'vendor/autoload.php')
174
+				: log_message('error', '$config[\'composer_autoload\'] is set to TRUE but '.APPPATH.'vendor/autoload.php was not found.');
175
+		}
176
+		elseif (file_exists($composer_autoload))
177
+		{
178
+			require_once($composer_autoload);
179
+		}
180
+		else
181
+		{
182
+			log_message('error', 'Could not find the specified $config[\'composer_autoload\'] path: '.$composer_autoload);
183
+		}
184
+	}
185
+
186
+/*
187
+ * ------------------------------------------------------
188
+ *  Start the timer... tick tock tick tock...
189
+ * ------------------------------------------------------
190
+ */
191
+	$BM =& load_class('Benchmark', 'core');
192
+	$BM->mark('total_execution_time_start');
193
+	$BM->mark('loading_time:_base_classes_start');
194
+
195
+/*
196
+ * ------------------------------------------------------
197
+ *  Instantiate the hooks class
198
+ * ------------------------------------------------------
199
+ */
200
+	$EXT =& load_class('Hooks', 'core');
201
+
202
+/*
203
+ * ------------------------------------------------------
204
+ *  Is there a "pre_system" hook?
205
+ * ------------------------------------------------------
206
+ */
207
+	$EXT->call_hook('pre_system');
208
+
209
+/*
210
+ * ------------------------------------------------------
211
+ *  Instantiate the config class
212
+ * ------------------------------------------------------
213
+ *
214
+ * Note: It is important that Config is loaded first as
215
+ * most other classes depend on it either directly or by
216
+ * depending on another class that uses it.
217
+ *
218
+ */
219
+	$CFG =& load_class('Config', 'core');
220
+
221
+	// Do we have any manually set config items in the index.php file?
222
+	if (isset($assign_to_config) && is_array($assign_to_config))
223
+	{
224
+		foreach ($assign_to_config as $key => $value)
225
+		{
226
+			$CFG->set_item($key, $value);
227
+		}
228
+	}
229
+
230
+/*
231
+ * ------------------------------------------------------
232
+ * Important charset-related stuff
233
+ * ------------------------------------------------------
234
+ *
235
+ * Configure mbstring and/or iconv if they are enabled
236
+ * and set MB_ENABLED and ICONV_ENABLED constants, so
237
+ * that we don't repeatedly do extension_loaded() or
238
+ * function_exists() calls.
239
+ *
240
+ * Note: UTF-8 class depends on this. It used to be done
241
+ * in it's constructor, but it's _not_ class-specific.
242
+ *
243
+ */
244
+	$charset = strtoupper(config_item('charset'));
245
+	ini_set('default_charset', $charset);
246
+
247
+	if (extension_loaded('mbstring'))
248
+	{
249
+		define('MB_ENABLED', TRUE);
250
+		// mbstring.internal_encoding is deprecated starting with PHP 5.6
251
+		// and it's usage triggers E_DEPRECATED messages.
252
+		@ini_set('mbstring.internal_encoding', $charset);
253
+		// This is required for mb_convert_encoding() to strip invalid characters.
254
+		// That's utilized by CI_Utf8, but it's also done for consistency with iconv.
255
+		mb_substitute_character('none');
256
+	}
257
+	else
258
+	{
259
+		define('MB_ENABLED', FALSE);
260
+	}
261
+
262
+	// There's an ICONV_IMPL constant, but the PHP manual says that using
263
+	// iconv's predefined constants is "strongly discouraged".
264
+	if (extension_loaded('iconv'))
265
+	{
266
+		define('ICONV_ENABLED', TRUE);
267
+		// iconv.internal_encoding is deprecated starting with PHP 5.6
268
+		// and it's usage triggers E_DEPRECATED messages.
269
+		@ini_set('iconv.internal_encoding', $charset);
270
+	}
271
+	else
272
+	{
273
+		define('ICONV_ENABLED', FALSE);
274
+	}
275
+
276
+	if (is_php('5.6'))
277
+	{
278
+		ini_set('php.internal_encoding', $charset);
279
+	}
280
+
281
+/*
282
+ * ------------------------------------------------------
283
+ *  Load compatibility features
284
+ * ------------------------------------------------------
285
+ */
286
+
287
+	require_once(BASEPATH.'core/compat/mbstring.php');
288
+	require_once(BASEPATH.'core/compat/hash.php');
289
+	require_once(BASEPATH.'core/compat/password.php');
290
+	require_once(BASEPATH.'core/compat/standard.php');
291
+
292
+/*
293
+ * ------------------------------------------------------
294
+ *  Instantiate the UTF-8 class
295
+ * ------------------------------------------------------
296
+ */
297
+	$UNI =& load_class('Utf8', 'core');
298
+
299
+/*
300
+ * ------------------------------------------------------
301
+ *  Instantiate the URI class
302
+ * ------------------------------------------------------
303
+ */
304
+	$URI =& load_class('URI', 'core');
305
+
306
+/*
307
+ * ------------------------------------------------------
308
+ *  Instantiate the routing class and set the routing
309
+ * ------------------------------------------------------
310
+ */
311
+	$RTR =& load_class('Router', 'core', isset($routing) ? $routing : NULL);
312
+
313
+/*
314
+ * ------------------------------------------------------
315
+ *  Instantiate the output class
316
+ * ------------------------------------------------------
317
+ */
318
+	$OUT =& load_class('Output', 'core');
319
+
320
+/*
321
+ * ------------------------------------------------------
322
+ *	Is there a valid cache file? If so, we're done...
323
+ * ------------------------------------------------------
324
+ */
325
+	if ($EXT->call_hook('cache_override') === FALSE && $OUT->_display_cache($CFG, $URI) === TRUE)
326
+	{
327
+		exit;
328
+	}
329
+
330
+/*
331
+ * -----------------------------------------------------
332
+ * Load the security class for xss and csrf support
333
+ * -----------------------------------------------------
334
+ */
335
+	$SEC =& load_class('Security', 'core');
336
+
337
+/*
338
+ * ------------------------------------------------------
339
+ *  Load the Input class and sanitize globals
340
+ * ------------------------------------------------------
341
+ */
342
+	$IN	=& load_class('Input', 'core');
343
+
344
+/*
345
+ * ------------------------------------------------------
346
+ *  Load the Language class
347
+ * ------------------------------------------------------
348
+ */
349
+	$LANG =& load_class('Lang', 'core');
350
+
351
+/*
352
+ * ------------------------------------------------------
353
+ *  Load the app controller and local controller
354
+ * ------------------------------------------------------
355
+ *
356
+ */
357
+	// Load the base controller class
358
+	require_once BASEPATH.'core/Controller.php';
359
+
360
+	/**
361
+	 * Reference to the CI_Controller method.
362
+	 *
363
+	 * Returns current CI instance object
364
+	 *
365
+	 * @return CI_Controller
366
+	 */
367
+	function &get_instance()
368
+	{
369
+		return CI_Controller::get_instance();
370
+	}
371
+
372
+	if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
373
+	{
374
+		require_once APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
375
+	}
376
+
377
+	// Set a mark point for benchmarking
378
+	$BM->mark('loading_time:_base_classes_end');
379
+
380
+/*
381
+ * ------------------------------------------------------
382
+ *  Sanity checks
383
+ * ------------------------------------------------------
384
+ *
385
+ *  The Router class has already validated the request,
386
+ *  leaving us with 3 options here:
387
+ *
388
+ *	1) an empty class name, if we reached the default
389
+ *	   controller, but it didn't exist;
390
+ *	2) a query string which doesn't go through a
391
+ *	   file_exists() check
392
+ *	3) a regular request for a non-existing page
393
+ *
394
+ *  We handle all of these as a 404 error.
395
+ *
396
+ *  Furthermore, none of the methods in the app controller
397
+ *  or the loader class can be called via the URI, nor can
398
+ *  controller methods that begin with an underscore.
399
+ */
400
+
401
+	$e404 = FALSE;
402
+	$class = ucfirst($RTR->class);
403
+	$method = $RTR->method;
404
+
405
+	if (empty($class) OR ! file_exists(APPPATH.'controllers/'.$RTR->directory.$class.'.php'))
406
+	{
407
+		$e404 = TRUE;
408
+	}
409
+	else
410
+	{
411
+		require_once(APPPATH.'controllers/'.$RTR->directory.$class.'.php');
412
+
413
+		if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method))
414
+		{
415
+			$e404 = TRUE;
416
+		}
417
+		elseif (method_exists($class, '_remap'))
418
+		{
419
+			$params = array($method, array_slice($URI->rsegments, 2));
420
+			$method = '_remap';
421
+		}
422
+		elseif ( ! method_exists($class, $method))
423
+		{
424
+			$e404 = TRUE;
425
+		}
426
+		/**
427
+		 * DO NOT CHANGE THIS, NOTHING ELSE WORKS!
428
+		 *
429
+		 * - method_exists() returns true for non-public methods, which passes the previous elseif
430
+		 * - is_callable() returns false for PHP 4-style constructors, even if there's a __construct()
431
+		 * - method_exists($class, '__construct') won't work because CI_Controller::__construct() is inherited
432
+		 * - People will only complain if this doesn't work, even though it is documented that it shouldn't.
433
+		 *
434
+		 * ReflectionMethod::isConstructor() is the ONLY reliable check,
435
+		 * knowing which method will be executed as a constructor.
436
+		 */
437
+		elseif ( ! is_callable(array($class, $method)))
438
+		{
439
+			$reflection = new ReflectionMethod($class, $method);
440
+			if ( ! $reflection->isPublic() OR $reflection->isConstructor())
441
+			{
442
+				$e404 = TRUE;
443
+			}
444
+		}
445
+	}
446
+
447
+	if ($e404)
448
+	{
449
+		if ( ! empty($RTR->routes['404_override']))
450
+		{
451
+			if (sscanf($RTR->routes['404_override'], '%[^/]/%s', $error_class, $error_method) !== 2)
452
+			{
453
+				$error_method = 'index';
454
+			}
455
+
456
+			$error_class = ucfirst($error_class);
457
+
458
+			if ( ! class_exists($error_class, FALSE))
459
+			{
460
+				if (file_exists(APPPATH.'controllers/'.$RTR->directory.$error_class.'.php'))
461
+				{
462
+					require_once(APPPATH.'controllers/'.$RTR->directory.$error_class.'.php');
463
+					$e404 = ! class_exists($error_class, FALSE);
464
+				}
465
+				// Were we in a directory? If so, check for a global override
466
+				elseif ( ! empty($RTR->directory) && file_exists(APPPATH.'controllers/'.$error_class.'.php'))
467
+				{
468
+					require_once(APPPATH.'controllers/'.$error_class.'.php');
469
+					if (($e404 = ! class_exists($error_class, FALSE)) === FALSE)
470
+					{
471
+						$RTR->directory = '';
472
+					}
473
+				}
474
+			}
475
+			else
476
+			{
477
+				$e404 = FALSE;
478
+			}
479
+		}
480
+
481
+		// Did we reset the $e404 flag? If so, set the rsegments, starting from index 1
482
+		if ( ! $e404)
483
+		{
484
+			$class = $error_class;
485
+			$method = $error_method;
486
+
487
+			$URI->rsegments = array(
488
+				1 => $class,
489
+				2 => $method
490
+			);
491
+		}
492
+		else
493
+		{
494
+			show_404($RTR->directory.$class.'/'.$method);
495
+		}
496
+	}
497
+
498
+	if ($method !== '_remap')
499
+	{
500
+		$params = array_slice($URI->rsegments, 2);
501
+	}
502
+
503
+/*
504
+ * ------------------------------------------------------
505
+ *  Is there a "pre_controller" hook?
506
+ * ------------------------------------------------------
507
+ */
508
+	$EXT->call_hook('pre_controller');
509
+
510
+/*
511
+ * ------------------------------------------------------
512
+ *  Instantiate the requested controller
513
+ * ------------------------------------------------------
514
+ */
515
+	// Mark a start point so we can benchmark the controller
516
+	$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
517
+
518
+	$CI = new $class();
519
+
520
+/*
521
+ * ------------------------------------------------------
522
+ *  Is there a "post_controller_constructor" hook?
523
+ * ------------------------------------------------------
524
+ */
525
+	$EXT->call_hook('post_controller_constructor');
526
+
527
+/*
528
+ * ------------------------------------------------------
529
+ *  Call the requested method
530
+ * ------------------------------------------------------
531
+ */
532
+	call_user_func_array(array(&$CI, $method), $params);
533
+
534
+	// Mark a benchmark end point
535
+	$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
536
+
537
+/*
538
+ * ------------------------------------------------------
539
+ *  Is there a "post_controller" hook?
540
+ * ------------------------------------------------------
541
+ */
542
+	$EXT->call_hook('post_controller');
543
+
544
+/*
545
+ * ------------------------------------------------------
546
+ *  Send the final rendered output to the browser
547
+ * ------------------------------------------------------
548
+ */
549
+	if ($EXT->call_hook('display_override') === FALSE)
550
+	{
551
+		$OUT->_display();
552
+	}
553
+
554
+/*
555
+ * ------------------------------------------------------
556
+ *  Is there a "post_system" hook?
557
+ * ------------------------------------------------------
558
+ */
559
+	$EXT->call_hook('post_system');

+ 849 - 0
system/core/Common.php Datei anzeigen

@@ -0,0 +1,849 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Common Functions
42
+ *
43
+ * Loads the base classes and executes the request.
44
+ *
45
+ * @package		CodeIgniter
46
+ * @subpackage	CodeIgniter
47
+ * @category	Common Functions
48
+ * @author		EllisLab Dev Team
49
+ * @link		https://codeigniter.com/user_guide/
50
+ */
51
+
52
+// ------------------------------------------------------------------------
53
+
54
+if ( ! function_exists('is_php'))
55
+{
56
+	/**
57
+	 * Determines if the current version of PHP is equal to or greater than the supplied value
58
+	 *
59
+	 * @param	string
60
+	 * @return	bool	TRUE if the current version is $version or higher
61
+	 */
62
+	function is_php($version)
63
+	{
64
+		static $_is_php;
65
+		$version = (string) $version;
66
+
67
+		if ( ! isset($_is_php[$version]))
68
+		{
69
+			$_is_php[$version] = version_compare(PHP_VERSION, $version, '>=');
70
+		}
71
+
72
+		return $_is_php[$version];
73
+	}
74
+}
75
+
76
+// ------------------------------------------------------------------------
77
+
78
+if ( ! function_exists('is_really_writable'))
79
+{
80
+	/**
81
+	 * Tests for file writability
82
+	 *
83
+	 * is_writable() returns TRUE on Windows servers when you really can't write to
84
+	 * the file, based on the read-only attribute. is_writable() is also unreliable
85
+	 * on Unix servers if safe_mode is on.
86
+	 *
87
+	 * @link	https://bugs.php.net/bug.php?id=54709
88
+	 * @param	string
89
+	 * @return	bool
90
+	 */
91
+	function is_really_writable($file)
92
+	{
93
+		// If we're on a Unix server with safe_mode off we call is_writable
94
+		if (DIRECTORY_SEPARATOR === '/' && (is_php('5.4') OR ! ini_get('safe_mode')))
95
+		{
96
+			return is_writable($file);
97
+		}
98
+
99
+		/* For Windows servers and safe_mode "on" installations we'll actually
100
+		 * write a file then read it. Bah...
101
+		 */
102
+		if (is_dir($file))
103
+		{
104
+			$file = rtrim($file, '/').'/'.md5(mt_rand());
105
+			if (($fp = @fopen($file, 'ab')) === FALSE)
106
+			{
107
+				return FALSE;
108
+			}
109
+
110
+			fclose($fp);
111
+			@chmod($file, 0777);
112
+			@unlink($file);
113
+			return TRUE;
114
+		}
115
+		elseif ( ! is_file($file) OR ($fp = @fopen($file, 'ab')) === FALSE)
116
+		{
117
+			return FALSE;
118
+		}
119
+
120
+		fclose($fp);
121
+		return TRUE;
122
+	}
123
+}
124
+
125
+// ------------------------------------------------------------------------
126
+
127
+if ( ! function_exists('load_class'))
128
+{
129
+	/**
130
+	 * Class registry
131
+	 *
132
+	 * This function acts as a singleton. If the requested class does not
133
+	 * exist it is instantiated and set to a static variable. If it has
134
+	 * previously been instantiated the variable is returned.
135
+	 *
136
+	 * @param	string	the class name being requested
137
+	 * @param	string	the directory where the class should be found
138
+	 * @param	mixed	an optional argument to pass to the class constructor
139
+	 * @return	object
140
+	 */
141
+	function &load_class($class, $directory = 'libraries', $param = NULL)
142
+	{
143
+		static $_classes = array();
144
+
145
+		// Does the class exist? If so, we're done...
146
+		if (isset($_classes[$class]))
147
+		{
148
+			return $_classes[$class];
149
+		}
150
+
151
+		$name = FALSE;
152
+
153
+		// Look for the class first in the local application/libraries folder
154
+		// then in the native system/libraries folder
155
+		foreach (array(APPPATH, BASEPATH) as $path)
156
+		{
157
+			if (file_exists($path.$directory.'/'.$class.'.php'))
158
+			{
159
+				$name = 'CI_'.$class;
160
+
161
+				if (class_exists($name, FALSE) === FALSE)
162
+				{
163
+					require_once($path.$directory.'/'.$class.'.php');
164
+				}
165
+
166
+				break;
167
+			}
168
+		}
169
+
170
+		// Is the request a class extension? If so we load it too
171
+		if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'))
172
+		{
173
+			$name = config_item('subclass_prefix').$class;
174
+
175
+			if (class_exists($name, FALSE) === FALSE)
176
+			{
177
+				require_once(APPPATH.$directory.'/'.$name.'.php');
178
+			}
179
+		}
180
+
181
+		// Did we find the class?
182
+		if ($name === FALSE)
183
+		{
184
+			// Note: We use exit() rather than show_error() in order to avoid a
185
+			// self-referencing loop with the Exceptions class
186
+			set_status_header(503);
187
+			echo 'Unable to locate the specified class: '.$class.'.php';
188
+			exit(5); // EXIT_UNK_CLASS
189
+		}
190
+
191
+		// Keep track of what we just loaded
192
+		is_loaded($class);
193
+
194
+		$_classes[$class] = isset($param)
195
+			? new $name($param)
196
+			: new $name();
197
+		return $_classes[$class];
198
+	}
199
+}
200
+
201
+// --------------------------------------------------------------------
202
+
203
+if ( ! function_exists('is_loaded'))
204
+{
205
+	/**
206
+	 * Keeps track of which libraries have been loaded. This function is
207
+	 * called by the load_class() function above
208
+	 *
209
+	 * @param	string
210
+	 * @return	array
211
+	 */
212
+	function &is_loaded($class = '')
213
+	{
214
+		static $_is_loaded = array();
215
+
216
+		if ($class !== '')
217
+		{
218
+			$_is_loaded[strtolower($class)] = $class;
219
+		}
220
+
221
+		return $_is_loaded;
222
+	}
223
+}
224
+
225
+// ------------------------------------------------------------------------
226
+
227
+if ( ! function_exists('get_config'))
228
+{
229
+	/**
230
+	 * Loads the main config.php file
231
+	 *
232
+	 * This function lets us grab the config file even if the Config class
233
+	 * hasn't been instantiated yet
234
+	 *
235
+	 * @param	array
236
+	 * @return	array
237
+	 */
238
+	function &get_config(Array $replace = array())
239
+	{
240
+		static $config;
241
+
242
+		if (empty($config))
243
+		{
244
+			$file_path = APPPATH.'config/config.php';
245
+			$found = FALSE;
246
+			if (file_exists($file_path))
247
+			{
248
+				$found = TRUE;
249
+				require($file_path);
250
+			}
251
+
252
+			// Is the config file in the environment folder?
253
+			if (file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
254
+			{
255
+				require($file_path);
256
+			}
257
+			elseif ( ! $found)
258
+			{
259
+				set_status_header(503);
260
+				echo 'The configuration file does not exist.';
261
+				exit(3); // EXIT_CONFIG
262
+			}
263
+
264
+			// Does the $config array exist in the file?
265
+			if ( ! isset($config) OR ! is_array($config))
266
+			{
267
+				set_status_header(503);
268
+				echo 'Your config file does not appear to be formatted correctly.';
269
+				exit(3); // EXIT_CONFIG
270
+			}
271
+		}
272
+
273
+		// Are any values being dynamically added or replaced?
274
+		foreach ($replace as $key => $val)
275
+		{
276
+			$config[$key] = $val;
277
+		}
278
+
279
+		return $config;
280
+	}
281
+}
282
+
283
+// ------------------------------------------------------------------------
284
+
285
+if ( ! function_exists('config_item'))
286
+{
287
+	/**
288
+	 * Returns the specified config item
289
+	 *
290
+	 * @param	string
291
+	 * @return	mixed
292
+	 */
293
+	function config_item($item)
294
+	{
295
+		static $_config;
296
+
297
+		if (empty($_config))
298
+		{
299
+			// references cannot be directly assigned to static variables, so we use an array
300
+			$_config[0] =& get_config();
301
+		}
302
+
303
+		return isset($_config[0][$item]) ? $_config[0][$item] : NULL;
304
+	}
305
+}
306
+
307
+// ------------------------------------------------------------------------
308
+
309
+if ( ! function_exists('get_mimes'))
310
+{
311
+	/**
312
+	 * Returns the MIME types array from config/mimes.php
313
+	 *
314
+	 * @return	array
315
+	 */
316
+	function &get_mimes()
317
+	{
318
+		static $_mimes;
319
+
320
+		if (empty($_mimes))
321
+		{
322
+			$_mimes = file_exists(APPPATH.'config/mimes.php')
323
+				? include(APPPATH.'config/mimes.php')
324
+				: array();
325
+
326
+			if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
327
+			{
328
+				$_mimes = array_merge($_mimes, include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'));
329
+			}
330
+		}
331
+
332
+		return $_mimes;
333
+	}
334
+}
335
+
336
+// ------------------------------------------------------------------------
337
+
338
+if ( ! function_exists('is_https'))
339
+{
340
+	/**
341
+	 * Is HTTPS?
342
+	 *
343
+	 * Determines if the application is accessed via an encrypted
344
+	 * (HTTPS) connection.
345
+	 *
346
+	 * @return	bool
347
+	 */
348
+	function is_https()
349
+	{
350
+		if ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')
351
+		{
352
+			return TRUE;
353
+		}
354
+		elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https')
355
+		{
356
+			return TRUE;
357
+		}
358
+		elseif ( ! empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off')
359
+		{
360
+			return TRUE;
361
+		}
362
+
363
+		return FALSE;
364
+	}
365
+}
366
+
367
+// ------------------------------------------------------------------------
368
+
369
+if ( ! function_exists('is_cli'))
370
+{
371
+
372
+	/**
373
+	 * Is CLI?
374
+	 *
375
+	 * Test to see if a request was made from the command line.
376
+	 *
377
+	 * @return 	bool
378
+	 */
379
+	function is_cli()
380
+	{
381
+		return (PHP_SAPI === 'cli' OR defined('STDIN'));
382
+	}
383
+}
384
+
385
+// ------------------------------------------------------------------------
386
+
387
+if ( ! function_exists('show_error'))
388
+{
389
+	/**
390
+	 * Error Handler
391
+	 *
392
+	 * This function lets us invoke the exception class and
393
+	 * display errors using the standard error template located
394
+	 * in application/views/errors/error_general.php
395
+	 * This function will send the error page directly to the
396
+	 * browser and exit.
397
+	 *
398
+	 * @param	string
399
+	 * @param	int
400
+	 * @param	string
401
+	 * @return	void
402
+	 */
403
+	function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered')
404
+	{
405
+		$status_code = abs($status_code);
406
+		if ($status_code < 100)
407
+		{
408
+			$exit_status = $status_code + 9; // 9 is EXIT__AUTO_MIN
409
+			$status_code = 500;
410
+		}
411
+		else
412
+		{
413
+			$exit_status = 1; // EXIT_ERROR
414
+		}
415
+
416
+		$_error =& load_class('Exceptions', 'core');
417
+		echo $_error->show_error($heading, $message, 'error_general', $status_code);
418
+		exit($exit_status);
419
+	}
420
+}
421
+
422
+// ------------------------------------------------------------------------
423
+
424
+if ( ! function_exists('show_404'))
425
+{
426
+	/**
427
+	 * 404 Page Handler
428
+	 *
429
+	 * This function is similar to the show_error() function above
430
+	 * However, instead of the standard error template it displays
431
+	 * 404 errors.
432
+	 *
433
+	 * @param	string
434
+	 * @param	bool
435
+	 * @return	void
436
+	 */
437
+	function show_404($page = '', $log_error = TRUE)
438
+	{
439
+		$_error =& load_class('Exceptions', 'core');
440
+		$_error->show_404($page, $log_error);
441
+		exit(4); // EXIT_UNKNOWN_FILE
442
+	}
443
+}
444
+
445
+// ------------------------------------------------------------------------
446
+
447
+if ( ! function_exists('log_message'))
448
+{
449
+	/**
450
+	 * Error Logging Interface
451
+	 *
452
+	 * We use this as a simple mechanism to access the logging
453
+	 * class and send messages to be logged.
454
+	 *
455
+	 * @param	string	the error level: 'error', 'debug' or 'info'
456
+	 * @param	string	the error message
457
+	 * @return	void
458
+	 */
459
+	function log_message($level, $message)
460
+	{
461
+		static $_log;
462
+
463
+		if ($_log === NULL)
464
+		{
465
+			// references cannot be directly assigned to static variables, so we use an array
466
+			$_log[0] =& load_class('Log', 'core');
467
+		}
468
+
469
+		$_log[0]->write_log($level, $message);
470
+	}
471
+}
472
+
473
+// ------------------------------------------------------------------------
474
+
475
+if ( ! function_exists('set_status_header'))
476
+{
477
+	/**
478
+	 * Set HTTP Status Header
479
+	 *
480
+	 * @param	int	the status code
481
+	 * @param	string
482
+	 * @return	void
483
+	 */
484
+	function set_status_header($code = 200, $text = '')
485
+	{
486
+		if (is_cli())
487
+		{
488
+			return;
489
+		}
490
+
491
+		if (empty($code) OR ! is_numeric($code))
492
+		{
493
+			show_error('Status codes must be numeric', 500);
494
+		}
495
+
496
+		if (empty($text))
497
+		{
498
+			is_int($code) OR $code = (int) $code;
499
+			$stati = array(
500
+				100	=> 'Continue',
501
+				101	=> 'Switching Protocols',
502
+
503
+				200	=> 'OK',
504
+				201	=> 'Created',
505
+				202	=> 'Accepted',
506
+				203	=> 'Non-Authoritative Information',
507
+				204	=> 'No Content',
508
+				205	=> 'Reset Content',
509
+				206	=> 'Partial Content',
510
+
511
+				300	=> 'Multiple Choices',
512
+				301	=> 'Moved Permanently',
513
+				302	=> 'Found',
514
+				303	=> 'See Other',
515
+				304	=> 'Not Modified',
516
+				305	=> 'Use Proxy',
517
+				307	=> 'Temporary Redirect',
518
+
519
+				400	=> 'Bad Request',
520
+				401	=> 'Unauthorized',
521
+				402	=> 'Payment Required',
522
+				403	=> 'Forbidden',
523
+				404	=> 'Not Found',
524
+				405	=> 'Method Not Allowed',
525
+				406	=> 'Not Acceptable',
526
+				407	=> 'Proxy Authentication Required',
527
+				408	=> 'Request Timeout',
528
+				409	=> 'Conflict',
529
+				410	=> 'Gone',
530
+				411	=> 'Length Required',
531
+				412	=> 'Precondition Failed',
532
+				413	=> 'Request Entity Too Large',
533
+				414	=> 'Request-URI Too Long',
534
+				415	=> 'Unsupported Media Type',
535
+				416	=> 'Requested Range Not Satisfiable',
536
+				417	=> 'Expectation Failed',
537
+				422	=> 'Unprocessable Entity',
538
+				426	=> 'Upgrade Required',
539
+				428	=> 'Precondition Required',
540
+				429	=> 'Too Many Requests',
541
+				431	=> 'Request Header Fields Too Large',
542
+
543
+				500	=> 'Internal Server Error',
544
+				501	=> 'Not Implemented',
545
+				502	=> 'Bad Gateway',
546
+				503	=> 'Service Unavailable',
547
+				504	=> 'Gateway Timeout',
548
+				505	=> 'HTTP Version Not Supported',
549
+				511	=> 'Network Authentication Required',
550
+			);
551
+
552
+			if (isset($stati[$code]))
553
+			{
554
+				$text = $stati[$code];
555
+			}
556
+			else
557
+			{
558
+				show_error('No status text available. Please check your status code number or supply your own message text.', 500);
559
+			}
560
+		}
561
+
562
+		if (strpos(PHP_SAPI, 'cgi') === 0)
563
+		{
564
+			header('Status: '.$code.' '.$text, TRUE);
565
+			return;
566
+		}
567
+
568
+		$server_protocol = (isset($_SERVER['SERVER_PROTOCOL']) && in_array($_SERVER['SERVER_PROTOCOL'], array('HTTP/1.0', 'HTTP/1.1', 'HTTP/2'), TRUE))
569
+			? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
570
+		header($server_protocol.' '.$code.' '.$text, TRUE, $code);
571
+	}
572
+}
573
+
574
+// --------------------------------------------------------------------
575
+
576
+if ( ! function_exists('_error_handler'))
577
+{
578
+	/**
579
+	 * Error Handler
580
+	 *
581
+	 * This is the custom error handler that is declared at the (relative)
582
+	 * top of CodeIgniter.php. The main reason we use this is to permit
583
+	 * PHP errors to be logged in our own log files since the user may
584
+	 * not have access to server logs. Since this function effectively
585
+	 * intercepts PHP errors, however, we also need to display errors
586
+	 * based on the current error_reporting level.
587
+	 * We do that with the use of a PHP error template.
588
+	 *
589
+	 * @param	int	$severity
590
+	 * @param	string	$message
591
+	 * @param	string	$filepath
592
+	 * @param	int	$line
593
+	 * @return	void
594
+	 */
595
+	function _error_handler($severity, $message, $filepath, $line)
596
+	{
597
+		$is_error = (((E_ERROR | E_PARSE | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $severity) === $severity);
598
+
599
+		// When an error occurred, set the status header to '500 Internal Server Error'
600
+		// to indicate to the client something went wrong.
601
+		// This can't be done within the $_error->show_php_error method because
602
+		// it is only called when the display_errors flag is set (which isn't usually
603
+		// the case in a production environment) or when errors are ignored because
604
+		// they are above the error_reporting threshold.
605
+		if ($is_error)
606
+		{
607
+			set_status_header(500);
608
+		}
609
+
610
+		// Should we ignore the error? We'll get the current error_reporting
611
+		// level and add its bits with the severity bits to find out.
612
+		if (($severity & error_reporting()) !== $severity)
613
+		{
614
+			return;
615
+		}
616
+
617
+		$_error =& load_class('Exceptions', 'core');
618
+		$_error->log_exception($severity, $message, $filepath, $line);
619
+
620
+		// Should we display the error?
621
+		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors')))
622
+		{
623
+			$_error->show_php_error($severity, $message, $filepath, $line);
624
+		}
625
+
626
+		// If the error is fatal, the execution of the script should be stopped because
627
+		// errors can't be recovered from. Halting the script conforms with PHP's
628
+		// default error handling. See http://www.php.net/manual/en/errorfunc.constants.php
629
+		if ($is_error)
630
+		{
631
+			exit(1); // EXIT_ERROR
632
+		}
633
+	}
634
+}
635
+
636
+// ------------------------------------------------------------------------
637
+
638
+if ( ! function_exists('_exception_handler'))
639
+{
640
+	/**
641
+	 * Exception Handler
642
+	 *
643
+	 * Sends uncaught exceptions to the logger and displays them
644
+	 * only if display_errors is On so that they don't show up in
645
+	 * production environments.
646
+	 *
647
+	 * @param	Exception	$exception
648
+	 * @return	void
649
+	 */
650
+	function _exception_handler($exception)
651
+	{
652
+		$_error =& load_class('Exceptions', 'core');
653
+		$_error->log_exception('error', 'Exception: '.$exception->getMessage(), $exception->getFile(), $exception->getLine());
654
+
655
+		is_cli() OR set_status_header(500);
656
+		// Should we display the error?
657
+		if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors')))
658
+		{
659
+			$_error->show_exception($exception);
660
+		}
661
+
662
+		exit(1); // EXIT_ERROR
663
+	}
664
+}
665
+
666
+// ------------------------------------------------------------------------
667
+
668
+if ( ! function_exists('_shutdown_handler'))
669
+{
670
+	/**
671
+	 * Shutdown Handler
672
+	 *
673
+	 * This is the shutdown handler that is declared at the top
674
+	 * of CodeIgniter.php. The main reason we use this is to simulate
675
+	 * a complete custom exception handler.
676
+	 *
677
+	 * E_STRICT is purposively neglected because such events may have
678
+	 * been caught. Duplication or none? None is preferred for now.
679
+	 *
680
+	 * @link	http://insomanic.me.uk/post/229851073/php-trick-catching-fatal-errors-e-error-with-a
681
+	 * @return	void
682
+	 */
683
+	function _shutdown_handler()
684
+	{
685
+		$last_error = error_get_last();
686
+		if (isset($last_error) &&
687
+			($last_error['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_COMPILE_WARNING)))
688
+		{
689
+			_error_handler($last_error['type'], $last_error['message'], $last_error['file'], $last_error['line']);
690
+		}
691
+	}
692
+}
693
+
694
+// --------------------------------------------------------------------
695
+
696
+if ( ! function_exists('remove_invisible_characters'))
697
+{
698
+	/**
699
+	 * Remove Invisible Characters
700
+	 *
701
+	 * This prevents sandwiching null characters
702
+	 * between ascii characters, like Java\0script.
703
+	 *
704
+	 * @param	string
705
+	 * @param	bool
706
+	 * @return	string
707
+	 */
708
+	function remove_invisible_characters($str, $url_encoded = TRUE)
709
+	{
710
+		$non_displayables = array();
711
+
712
+		// every control character except newline (dec 10),
713
+		// carriage return (dec 13) and horizontal tab (dec 09)
714
+		if ($url_encoded)
715
+		{
716
+			$non_displayables[] = '/%0[0-8bcef]/i';	// url encoded 00-08, 11, 12, 14, 15
717
+			$non_displayables[] = '/%1[0-9a-f]/i';	// url encoded 16-31
718
+			$non_displayables[] = '/%7f/i';	// url encoded 127
719
+		}
720
+
721
+		$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S';	// 00-08, 11, 12, 14-31, 127
722
+
723
+		do
724
+		{
725
+			$str = preg_replace($non_displayables, '', $str, -1, $count);
726
+		}
727
+		while ($count);
728
+
729
+		return $str;
730
+	}
731
+}
732
+
733
+// ------------------------------------------------------------------------
734
+
735
+if ( ! function_exists('html_escape'))
736
+{
737
+	/**
738
+	 * Returns HTML escaped variable.
739
+	 *
740
+	 * @param	mixed	$var		The input string or array of strings to be escaped.
741
+	 * @param	bool	$double_encode	$double_encode set to FALSE prevents escaping twice.
742
+	 * @return	mixed			The escaped string or array of strings as a result.
743
+	 */
744
+	function html_escape($var, $double_encode = TRUE)
745
+	{
746
+		if (empty($var))
747
+		{
748
+			return $var;
749
+		}
750
+
751
+		if (is_array($var))
752
+		{
753
+			foreach (array_keys($var) as $key)
754
+			{
755
+				$var[$key] = html_escape($var[$key], $double_encode);
756
+			}
757
+
758
+			return $var;
759
+		}
760
+
761
+		return htmlspecialchars($var, ENT_QUOTES, config_item('charset'), $double_encode);
762
+	}
763
+}
764
+
765
+// ------------------------------------------------------------------------
766
+
767
+if ( ! function_exists('_stringify_attributes'))
768
+{
769
+	/**
770
+	 * Stringify attributes for use in HTML tags.
771
+	 *
772
+	 * Helper function used to convert a string, array, or object
773
+	 * of attributes to a string.
774
+	 *
775
+	 * @param	mixed	string, array, object
776
+	 * @param	bool
777
+	 * @return	string
778
+	 */
779
+	function _stringify_attributes($attributes, $js = FALSE)
780
+	{
781
+		$atts = NULL;
782
+
783
+		if (empty($attributes))
784
+		{
785
+			return $atts;
786
+		}
787
+
788
+		if (is_string($attributes))
789
+		{
790
+			return ' '.$attributes;
791
+		}
792
+
793
+		$attributes = (array) $attributes;
794
+
795
+		foreach ($attributes as $key => $val)
796
+		{
797
+			$atts .= ($js) ? $key.'='.$val.',' : ' '.$key.'="'.$val.'"';
798
+		}
799
+
800
+		return rtrim($atts, ',');
801
+	}
802
+}
803
+
804
+// ------------------------------------------------------------------------
805
+
806
+if ( ! function_exists('function_usable'))
807
+{
808
+	/**
809
+	 * Function usable
810
+	 *
811
+	 * Executes a function_exists() check, and if the Suhosin PHP
812
+	 * extension is loaded - checks whether the function that is
813
+	 * checked might be disabled in there as well.
814
+	 *
815
+	 * This is useful as function_exists() will return FALSE for
816
+	 * functions disabled via the *disable_functions* php.ini
817
+	 * setting, but not for *suhosin.executor.func.blacklist* and
818
+	 * *suhosin.executor.disable_eval*. These settings will just
819
+	 * terminate script execution if a disabled function is executed.
820
+	 *
821
+	 * The above described behavior turned out to be a bug in Suhosin,
822
+	 * but even though a fix was committed for 0.9.34 on 2012-02-12,
823
+	 * that version is yet to be released. This function will therefore
824
+	 * be just temporary, but would probably be kept for a few years.
825
+	 *
826
+	 * @link	http://www.hardened-php.net/suhosin/
827
+	 * @param	string	$function_name	Function to check for
828
+	 * @return	bool	TRUE if the function exists and is safe to call,
829
+	 *			FALSE otherwise.
830
+	 */
831
+	function function_usable($function_name)
832
+	{
833
+		static $_suhosin_func_blacklist;
834
+
835
+		if (function_exists($function_name))
836
+		{
837
+			if ( ! isset($_suhosin_func_blacklist))
838
+			{
839
+				$_suhosin_func_blacklist = extension_loaded('suhosin')
840
+					? explode(',', trim(ini_get('suhosin.executor.func.blacklist')))
841
+					: array();
842
+			}
843
+
844
+			return ! in_array($function_name, $_suhosin_func_blacklist, TRUE);
845
+		}
846
+
847
+		return FALSE;
848
+	}
849
+}

+ 379 - 0
system/core/Config.php Datei anzeigen

@@ -0,0 +1,379 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Config Class
42
+ *
43
+ * This class contains functions that enable config files to be managed
44
+ *
45
+ * @package		CodeIgniter
46
+ * @subpackage	Libraries
47
+ * @category	Libraries
48
+ * @author		EllisLab Dev Team
49
+ * @link		https://codeigniter.com/user_guide/libraries/config.html
50
+ */
51
+class CI_Config {
52
+
53
+	/**
54
+	 * List of all loaded config values
55
+	 *
56
+	 * @var	array
57
+	 */
58
+	public $config = array();
59
+
60
+	/**
61
+	 * List of all loaded config files
62
+	 *
63
+	 * @var	array
64
+	 */
65
+	public $is_loaded =	array();
66
+
67
+	/**
68
+	 * List of paths to search when trying to load a config file.
69
+	 *
70
+	 * @used-by	CI_Loader
71
+	 * @var		array
72
+	 */
73
+	public $_config_paths =	array(APPPATH);
74
+
75
+	// --------------------------------------------------------------------
76
+
77
+	/**
78
+	 * Class constructor
79
+	 *
80
+	 * Sets the $config data from the primary config.php file as a class variable.
81
+	 *
82
+	 * @return	void
83
+	 */
84
+	public function __construct()
85
+	{
86
+		$this->config =& get_config();
87
+
88
+		// Set the base_url automatically if none was provided
89
+		if (empty($this->config['base_url']))
90
+		{
91
+			if (isset($_SERVER['SERVER_ADDR']))
92
+			{
93
+				if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE)
94
+				{
95
+					$server_addr = '['.$_SERVER['SERVER_ADDR'].']';
96
+				}
97
+				else
98
+				{
99
+					$server_addr = $_SERVER['SERVER_ADDR'];
100
+				}
101
+
102
+				$base_url = (is_https() ? 'https' : 'http').'://'.$server_addr
103
+					.substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
104
+			}
105
+			else
106
+			{
107
+				$base_url = 'http://localhost/';
108
+			}
109
+
110
+			$this->set_item('base_url', $base_url);
111
+		}
112
+
113
+		log_message('info', 'Config Class Initialized');
114
+	}
115
+
116
+	// --------------------------------------------------------------------
117
+
118
+	/**
119
+	 * Load Config File
120
+	 *
121
+	 * @param	string	$file			Configuration file name
122
+	 * @param	bool	$use_sections		Whether configuration values should be loaded into their own section
123
+	 * @param	bool	$fail_gracefully	Whether to just return FALSE or display an error message
124
+	 * @return	bool	TRUE if the file was loaded correctly or FALSE on failure
125
+	 */
126
+	public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
127
+	{
128
+		$file = ($file === '') ? 'config' : str_replace('.php', '', $file);
129
+		$loaded = FALSE;
130
+
131
+		foreach ($this->_config_paths as $path)
132
+		{
133
+			foreach (array($file, ENVIRONMENT.DIRECTORY_SEPARATOR.$file) as $location)
134
+			{
135
+				$file_path = $path.'config/'.$location.'.php';
136
+				if (in_array($file_path, $this->is_loaded, TRUE))
137
+				{
138
+					return TRUE;
139
+				}
140
+
141
+				if ( ! file_exists($file_path))
142
+				{
143
+					continue;
144
+				}
145
+
146
+				include($file_path);
147
+
148
+				if ( ! isset($config) OR ! is_array($config))
149
+				{
150
+					if ($fail_gracefully === TRUE)
151
+					{
152
+						return FALSE;
153
+					}
154
+
155
+					show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
156
+				}
157
+
158
+				if ($use_sections === TRUE)
159
+				{
160
+					$this->config[$file] = isset($this->config[$file])
161
+						? array_merge($this->config[$file], $config)
162
+						: $config;
163
+				}
164
+				else
165
+				{
166
+					$this->config = array_merge($this->config, $config);
167
+				}
168
+
169
+				$this->is_loaded[] = $file_path;
170
+				$config = NULL;
171
+				$loaded = TRUE;
172
+				log_message('debug', 'Config file loaded: '.$file_path);
173
+			}
174
+		}
175
+
176
+		if ($loaded === TRUE)
177
+		{
178
+			return TRUE;
179
+		}
180
+		elseif ($fail_gracefully === TRUE)
181
+		{
182
+			return FALSE;
183
+		}
184
+
185
+		show_error('The configuration file '.$file.'.php does not exist.');
186
+	}
187
+
188
+	// --------------------------------------------------------------------
189
+
190
+	/**
191
+	 * Fetch a config file item
192
+	 *
193
+	 * @param	string	$item	Config item name
194
+	 * @param	string	$index	Index name
195
+	 * @return	string|null	The configuration item or NULL if the item doesn't exist
196
+	 */
197
+	public function item($item, $index = '')
198
+	{
199
+		if ($index == '')
200
+		{
201
+			return isset($this->config[$item]) ? $this->config[$item] : NULL;
202
+		}
203
+
204
+		return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : NULL;
205
+	}
206
+
207
+	// --------------------------------------------------------------------
208
+
209
+	/**
210
+	 * Fetch a config file item with slash appended (if not empty)
211
+	 *
212
+	 * @param	string		$item	Config item name
213
+	 * @return	string|null	The configuration item or NULL if the item doesn't exist
214
+	 */
215
+	public function slash_item($item)
216
+	{
217
+		if ( ! isset($this->config[$item]))
218
+		{
219
+			return NULL;
220
+		}
221
+		elseif (trim($this->config[$item]) === '')
222
+		{
223
+			return '';
224
+		}
225
+
226
+		return rtrim($this->config[$item], '/').'/';
227
+	}
228
+
229
+	// --------------------------------------------------------------------
230
+
231
+	/**
232
+	 * Site URL
233
+	 *
234
+	 * Returns base_url . index_page [. uri_string]
235
+	 *
236
+	 * @uses	CI_Config::_uri_string()
237
+	 *
238
+	 * @param	string|string[]	$uri	URI string or an array of segments
239
+	 * @param	string	$protocol
240
+	 * @return	string
241
+	 */
242
+	public function site_url($uri = '', $protocol = NULL)
243
+	{
244
+		$base_url = $this->slash_item('base_url');
245
+
246
+		if (isset($protocol))
247
+		{
248
+			// For protocol-relative links
249
+			if ($protocol === '')
250
+			{
251
+				$base_url = substr($base_url, strpos($base_url, '//'));
252
+			}
253
+			else
254
+			{
255
+				$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
256
+			}
257
+		}
258
+
259
+		if (empty($uri))
260
+		{
261
+			return $base_url.$this->item('index_page');
262
+		}
263
+
264
+		$uri = $this->_uri_string($uri);
265
+
266
+		if ($this->item('enable_query_strings') === FALSE)
267
+		{
268
+			$suffix = isset($this->config['url_suffix']) ? $this->config['url_suffix'] : '';
269
+
270
+			if ($suffix !== '')
271
+			{
272
+				if (($offset = strpos($uri, '?')) !== FALSE)
273
+				{
274
+					$uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset);
275
+				}
276
+				else
277
+				{
278
+					$uri .= $suffix;
279
+				}
280
+			}
281
+
282
+			return $base_url.$this->slash_item('index_page').$uri;
283
+		}
284
+		elseif (strpos($uri, '?') === FALSE)
285
+		{
286
+			$uri = '?'.$uri;
287
+		}
288
+
289
+		return $base_url.$this->item('index_page').$uri;
290
+	}
291
+
292
+	// -------------------------------------------------------------
293
+
294
+	/**
295
+	 * Base URL
296
+	 *
297
+	 * Returns base_url [. uri_string]
298
+	 *
299
+	 * @uses	CI_Config::_uri_string()
300
+	 *
301
+	 * @param	string|string[]	$uri	URI string or an array of segments
302
+	 * @param	string	$protocol
303
+	 * @return	string
304
+	 */
305
+	public function base_url($uri = '', $protocol = NULL)
306
+	{
307
+		$base_url = $this->slash_item('base_url');
308
+
309
+		if (isset($protocol))
310
+		{
311
+			// For protocol-relative links
312
+			if ($protocol === '')
313
+			{
314
+				$base_url = substr($base_url, strpos($base_url, '//'));
315
+			}
316
+			else
317
+			{
318
+				$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
319
+			}
320
+		}
321
+
322
+		return $base_url.$this->_uri_string($uri);
323
+	}
324
+
325
+	// -------------------------------------------------------------
326
+
327
+	/**
328
+	 * Build URI string
329
+	 *
330
+	 * @used-by	CI_Config::site_url()
331
+	 * @used-by	CI_Config::base_url()
332
+	 *
333
+	 * @param	string|string[]	$uri	URI string or an array of segments
334
+	 * @return	string
335
+	 */
336
+	protected function _uri_string($uri)
337
+	{
338
+		if ($this->item('enable_query_strings') === FALSE)
339
+		{
340
+			is_array($uri) && $uri = implode('/', $uri);
341
+			return ltrim($uri, '/');
342
+		}
343
+		elseif (is_array($uri))
344
+		{
345
+			return http_build_query($uri);
346
+		}
347
+
348
+		return $uri;
349
+	}
350
+
351
+	// --------------------------------------------------------------------
352
+
353
+	/**
354
+	 * System URL
355
+	 *
356
+	 * @deprecated	3.0.0	Encourages insecure practices
357
+	 * @return	string
358
+	 */
359
+	public function system_url()
360
+	{
361
+		$x = explode('/', preg_replace('|/*(.+?)/*$|', '\\1', BASEPATH));
362
+		return $this->slash_item('base_url').end($x).'/';
363
+	}
364
+
365
+	// --------------------------------------------------------------------
366
+
367
+	/**
368
+	 * Set a config file item
369
+	 *
370
+	 * @param	string	$item	Config item key
371
+	 * @param	string	$value	Config item value
372
+	 * @return	void
373
+	 */
374
+	public function set_item($item, $value)
375
+	{
376
+		$this->config[$item] = $value;
377
+	}
378
+
379
+}

+ 103 - 0
system/core/Controller.php Datei anzeigen

@@ -0,0 +1,103 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Application Controller Class
42
+ *
43
+ * This class object is the super class that every library in
44
+ * CodeIgniter will be assigned to.
45
+ *
46
+ * @package		CodeIgniter
47
+ * @subpackage	Libraries
48
+ * @category	Libraries
49
+ * @author		EllisLab Dev Team
50
+ * @link		https://codeigniter.com/user_guide/general/controllers.html
51
+ */
52
+class CI_Controller {
53
+
54
+	/**
55
+	 * Reference to the CI singleton
56
+	 *
57
+	 * @var	object
58
+	 */
59
+	private static $instance;
60
+
61
+	/**
62
+	 * CI_Loader
63
+	 *
64
+	 * @var	CI_Loader
65
+	 */
66
+	public $load;
67
+
68
+	/**
69
+	 * Class constructor
70
+	 *
71
+	 * @return	void
72
+	 */
73
+	public function __construct()
74
+	{
75
+		self::$instance =& $this;
76
+
77
+		// Assign all the class objects that were instantiated by the
78
+		// bootstrap file (CodeIgniter.php) to local class variables
79
+		// so that CI can run as one big super object.
80
+		foreach (is_loaded() as $var => $class)
81
+		{
82
+			$this->$var =& load_class($class);
83
+		}
84
+
85
+		$this->load =& load_class('Loader', 'core');
86
+		$this->load->initialize();
87
+		log_message('info', 'Controller Class Initialized');
88
+	}
89
+
90
+	// --------------------------------------------------------------------
91
+
92
+	/**
93
+	 * Get the CI singleton
94
+	 *
95
+	 * @static
96
+	 * @return	object
97
+	 */
98
+	public static function &get_instance()
99
+	{
100
+		return self::$instance;
101
+	}
102
+
103
+}

+ 274 - 0
system/core/Exceptions.php Datei anzeigen

@@ -0,0 +1,274 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Exceptions Class
42
+ *
43
+ * @package		CodeIgniter
44
+ * @subpackage	Libraries
45
+ * @category	Exceptions
46
+ * @author		EllisLab Dev Team
47
+ * @link		https://codeigniter.com/user_guide/libraries/exceptions.html
48
+ */
49
+class CI_Exceptions {
50
+
51
+	/**
52
+	 * Nesting level of the output buffering mechanism
53
+	 *
54
+	 * @var	int
55
+	 */
56
+	public $ob_level;
57
+
58
+	/**
59
+	 * List of available error levels
60
+	 *
61
+	 * @var	array
62
+	 */
63
+	public $levels = array(
64
+		E_ERROR			=>	'Error',
65
+		E_WARNING		=>	'Warning',
66
+		E_PARSE			=>	'Parsing Error',
67
+		E_NOTICE		=>	'Notice',
68
+		E_CORE_ERROR		=>	'Core Error',
69
+		E_CORE_WARNING		=>	'Core Warning',
70
+		E_COMPILE_ERROR		=>	'Compile Error',
71
+		E_COMPILE_WARNING	=>	'Compile Warning',
72
+		E_USER_ERROR		=>	'User Error',
73
+		E_USER_WARNING		=>	'User Warning',
74
+		E_USER_NOTICE		=>	'User Notice',
75
+		E_STRICT		=>	'Runtime Notice'
76
+	);
77
+
78
+	/**
79
+	 * Class constructor
80
+	 *
81
+	 * @return	void
82
+	 */
83
+	public function __construct()
84
+	{
85
+		$this->ob_level = ob_get_level();
86
+		// Note: Do not log messages from this constructor.
87
+	}
88
+
89
+	// --------------------------------------------------------------------
90
+
91
+	/**
92
+	 * Exception Logger
93
+	 *
94
+	 * Logs PHP generated error messages
95
+	 *
96
+	 * @param	int	$severity	Log level
97
+	 * @param	string	$message	Error message
98
+	 * @param	string	$filepath	File path
99
+	 * @param	int	$line		Line number
100
+	 * @return	void
101
+	 */
102
+	public function log_exception($severity, $message, $filepath, $line)
103
+	{
104
+		$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
105
+		log_message('error', 'Severity: '.$severity.' --> '.$message.' '.$filepath.' '.$line);
106
+	}
107
+
108
+	// --------------------------------------------------------------------
109
+
110
+	/**
111
+	 * 404 Error Handler
112
+	 *
113
+	 * @uses	CI_Exceptions::show_error()
114
+	 *
115
+	 * @param	string	$page		Page URI
116
+	 * @param 	bool	$log_error	Whether to log the error
117
+	 * @return	void
118
+	 */
119
+	public function show_404($page = '', $log_error = TRUE)
120
+	{
121
+		if (is_cli())
122
+		{
123
+			$heading = 'Not Found';
124
+			$message = 'The controller/method pair you requested was not found.';
125
+		}
126
+		else
127
+		{
128
+			$heading = '404 Page Not Found';
129
+			$message = 'The page you requested was not found.';
130
+		}
131
+
132
+		// By default we log this, but allow a dev to skip it
133
+		if ($log_error)
134
+		{
135
+			log_message('error', $heading.': '.$page);
136
+		}
137
+
138
+		echo $this->show_error($heading, $message, 'error_404', 404);
139
+		exit(4); // EXIT_UNKNOWN_FILE
140
+	}
141
+
142
+	// --------------------------------------------------------------------
143
+
144
+	/**
145
+	 * General Error Page
146
+	 *
147
+	 * Takes an error message as input (either as a string or an array)
148
+	 * and displays it using the specified template.
149
+	 *
150
+	 * @param	string		$heading	Page heading
151
+	 * @param	string|string[]	$message	Error message
152
+	 * @param	string		$template	Template name
153
+	 * @param 	int		$status_code	(default: 500)
154
+	 *
155
+	 * @return	string	Error page output
156
+	 */
157
+	public function show_error($heading, $message, $template = 'error_general', $status_code = 500)
158
+	{
159
+		$templates_path = config_item('error_views_path');
160
+		if (empty($templates_path))
161
+		{
162
+			$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
163
+		}
164
+
165
+		if (is_cli())
166
+		{
167
+			$message = "\t".(is_array($message) ? implode("\n\t", $message) : $message);
168
+			$template = 'cli'.DIRECTORY_SEPARATOR.$template;
169
+		}
170
+		else
171
+		{
172
+			set_status_header($status_code);
173
+			$message = '<p>'.(is_array($message) ? implode('</p><p>', $message) : $message).'</p>';
174
+			$template = 'html'.DIRECTORY_SEPARATOR.$template;
175
+		}
176
+
177
+		if (ob_get_level() > $this->ob_level + 1)
178
+		{
179
+			ob_end_flush();
180
+		}
181
+		ob_start();
182
+		include($templates_path.$template.'.php');
183
+		$buffer = ob_get_contents();
184
+		ob_end_clean();
185
+		return $buffer;
186
+	}
187
+
188
+	// --------------------------------------------------------------------
189
+
190
+	public function show_exception($exception)
191
+	{
192
+		$templates_path = config_item('error_views_path');
193
+		if (empty($templates_path))
194
+		{
195
+			$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
196
+		}
197
+
198
+		$message = $exception->getMessage();
199
+		if (empty($message))
200
+		{
201
+			$message = '(null)';
202
+		}
203
+
204
+		if (is_cli())
205
+		{
206
+			$templates_path .= 'cli'.DIRECTORY_SEPARATOR;
207
+		}
208
+		else
209
+		{
210
+			$templates_path .= 'html'.DIRECTORY_SEPARATOR;
211
+		}
212
+
213
+		if (ob_get_level() > $this->ob_level + 1)
214
+		{
215
+			ob_end_flush();
216
+		}
217
+
218
+		ob_start();
219
+		include($templates_path.'error_exception.php');
220
+		$buffer = ob_get_contents();
221
+		ob_end_clean();
222
+		echo $buffer;
223
+	}
224
+
225
+	// --------------------------------------------------------------------
226
+
227
+	/**
228
+	 * Native PHP error handler
229
+	 *
230
+	 * @param	int	$severity	Error level
231
+	 * @param	string	$message	Error message
232
+	 * @param	string	$filepath	File path
233
+	 * @param	int	$line		Line number
234
+	 * @return	void
235
+	 */
236
+	public function show_php_error($severity, $message, $filepath, $line)
237
+	{
238
+		$templates_path = config_item('error_views_path');
239
+		if (empty($templates_path))
240
+		{
241
+			$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
242
+		}
243
+
244
+		$severity = isset($this->levels[$severity]) ? $this->levels[$severity] : $severity;
245
+
246
+		// For safety reasons we don't show the full file path in non-CLI requests
247
+		if ( ! is_cli())
248
+		{
249
+			$filepath = str_replace('\\', '/', $filepath);
250
+			if (FALSE !== strpos($filepath, '/'))
251
+			{
252
+				$x = explode('/', $filepath);
253
+				$filepath = $x[count($x)-2].'/'.end($x);
254
+			}
255
+
256
+			$template = 'html'.DIRECTORY_SEPARATOR.'error_php';
257
+		}
258
+		else
259
+		{
260
+			$template = 'cli'.DIRECTORY_SEPARATOR.'error_php';
261
+		}
262
+
263
+		if (ob_get_level() > $this->ob_level + 1)
264
+		{
265
+			ob_end_flush();
266
+		}
267
+		ob_start();
268
+		include($templates_path.$template.'.php');
269
+		$buffer = ob_get_contents();
270
+		ob_end_clean();
271
+		echo $buffer;
272
+	}
273
+
274
+}

+ 266 - 0
system/core/Hooks.php Datei anzeigen

@@ -0,0 +1,266 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Hooks Class
42
+ *
43
+ * Provides a mechanism to extend the base system without hacking.
44
+ *
45
+ * @package		CodeIgniter
46
+ * @subpackage	Libraries
47
+ * @category	Libraries
48
+ * @author		EllisLab Dev Team
49
+ * @link		https://codeigniter.com/user_guide/general/hooks.html
50
+ */
51
+class CI_Hooks {
52
+
53
+	/**
54
+	 * Determines whether hooks are enabled
55
+	 *
56
+	 * @var	bool
57
+	 */
58
+	public $enabled = FALSE;
59
+
60
+	/**
61
+	 * List of all hooks set in config/hooks.php
62
+	 *
63
+	 * @var	array
64
+	 */
65
+	public $hooks =	array();
66
+
67
+	/**
68
+	 * Array with class objects to use hooks methods
69
+	 *
70
+	 * @var array
71
+	 */
72
+	protected $_objects = array();
73
+
74
+	/**
75
+	 * In progress flag
76
+	 *
77
+	 * Determines whether hook is in progress, used to prevent infinte loops
78
+	 *
79
+	 * @var	bool
80
+	 */
81
+	protected $_in_progress = FALSE;
82
+
83
+	/**
84
+	 * Class constructor
85
+	 *
86
+	 * @return	void
87
+	 */
88
+	public function __construct()
89
+	{
90
+		$CFG =& load_class('Config', 'core');
91
+		log_message('info', 'Hooks Class Initialized');
92
+
93
+		// If hooks are not enabled in the config file
94
+		// there is nothing else to do
95
+		if ($CFG->item('enable_hooks') === FALSE)
96
+		{
97
+			return;
98
+		}
99
+
100
+		// Grab the "hooks" definition file.
101
+		if (file_exists(APPPATH.'config/hooks.php'))
102
+		{
103
+			include(APPPATH.'config/hooks.php');
104
+		}
105
+
106
+		if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
107
+		{
108
+			include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
109
+		}
110
+
111
+		// If there are no hooks, we're done.
112
+		if ( ! isset($hook) OR ! is_array($hook))
113
+		{
114
+			return;
115
+		}
116
+
117
+		$this->hooks =& $hook;
118
+		$this->enabled = TRUE;
119
+	}
120
+
121
+	// --------------------------------------------------------------------
122
+
123
+	/**
124
+	 * Call Hook
125
+	 *
126
+	 * Calls a particular hook. Called by CodeIgniter.php.
127
+	 *
128
+	 * @uses	CI_Hooks::_run_hook()
129
+	 *
130
+	 * @param	string	$which	Hook name
131
+	 * @return	bool	TRUE on success or FALSE on failure
132
+	 */
133
+	public function call_hook($which = '')
134
+	{
135
+		if ( ! $this->enabled OR ! isset($this->hooks[$which]))
136
+		{
137
+			return FALSE;
138
+		}
139
+
140
+		if (is_array($this->hooks[$which]) && ! isset($this->hooks[$which]['function']))
141
+		{
142
+			foreach ($this->hooks[$which] as $val)
143
+			{
144
+				$this->_run_hook($val);
145
+			}
146
+		}
147
+		else
148
+		{
149
+			$this->_run_hook($this->hooks[$which]);
150
+		}
151
+
152
+		return TRUE;
153
+	}
154
+
155
+	// --------------------------------------------------------------------
156
+
157
+	/**
158
+	 * Run Hook
159
+	 *
160
+	 * Runs a particular hook
161
+	 *
162
+	 * @param	array	$data	Hook details
163
+	 * @return	bool	TRUE on success or FALSE on failure
164
+	 */
165
+	protected function _run_hook($data)
166
+	{
167
+		// Closures/lambda functions and array($object, 'method') callables
168
+		if (is_callable($data))
169
+		{
170
+			is_array($data)
171
+				? $data[0]->{$data[1]}()
172
+				: $data();
173
+
174
+			return TRUE;
175
+		}
176
+		elseif ( ! is_array($data))
177
+		{
178
+			return FALSE;
179
+		}
180
+
181
+		// -----------------------------------
182
+		// Safety - Prevents run-away loops
183
+		// -----------------------------------
184
+
185
+		// If the script being called happens to have the same
186
+		// hook call within it a loop can happen
187
+		if ($this->_in_progress === TRUE)
188
+		{
189
+			return;
190
+		}
191
+
192
+		// -----------------------------------
193
+		// Set file path
194
+		// -----------------------------------
195
+
196
+		if ( ! isset($data['filepath'], $data['filename']))
197
+		{
198
+			return FALSE;
199
+		}
200
+
201
+		$filepath = APPPATH.$data['filepath'].'/'.$data['filename'];
202
+
203
+		if ( ! file_exists($filepath))
204
+		{
205
+			return FALSE;
206
+		}
207
+
208
+		// Determine and class and/or function names
209
+		$class		= empty($data['class']) ? FALSE : $data['class'];
210
+		$function	= empty($data['function']) ? FALSE : $data['function'];
211
+		$params		= isset($data['params']) ? $data['params'] : '';
212
+
213
+		if (empty($function))
214
+		{
215
+			return FALSE;
216
+		}
217
+
218
+		// Set the _in_progress flag
219
+		$this->_in_progress = TRUE;
220
+
221
+		// Call the requested class and/or function
222
+		if ($class !== FALSE)
223
+		{
224
+			// The object is stored?
225
+			if (isset($this->_objects[$class]))
226
+			{
227
+				if (method_exists($this->_objects[$class], $function))
228
+				{
229
+					$this->_objects[$class]->$function($params);
230
+				}
231
+				else
232
+				{
233
+					return $this->_in_progress = FALSE;
234
+				}
235
+			}
236
+			else
237
+			{
238
+				class_exists($class, FALSE) OR require_once($filepath);
239
+
240
+				if ( ! class_exists($class, FALSE) OR ! method_exists($class, $function))
241
+				{
242
+					return $this->_in_progress = FALSE;
243
+				}
244
+
245
+				// Store the object and execute the method
246
+				$this->_objects[$class] = new $class();
247
+				$this->_objects[$class]->$function($params);
248
+			}
249
+		}
250
+		else
251
+		{
252
+			function_exists($function) OR require_once($filepath);
253
+
254
+			if ( ! function_exists($function))
255
+			{
256
+				return $this->_in_progress = FALSE;
257
+			}
258
+
259
+			$function($params);
260
+		}
261
+
262
+		$this->_in_progress = FALSE;
263
+		return TRUE;
264
+	}
265
+
266
+}

+ 895 - 0
system/core/Input.php Datei anzeigen

@@ -0,0 +1,895 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Input Class
42
+ *
43
+ * Pre-processes global input data for security
44
+ *
45
+ * @package		CodeIgniter
46
+ * @subpackage	Libraries
47
+ * @category	Input
48
+ * @author		EllisLab Dev Team
49
+ * @link		https://codeigniter.com/user_guide/libraries/input.html
50
+ */
51
+class CI_Input {
52
+
53
+	/**
54
+	 * IP address of the current user
55
+	 *
56
+	 * @var	string
57
+	 */
58
+	protected $ip_address = FALSE;
59
+
60
+	/**
61
+	 * Allow GET array flag
62
+	 *
63
+	 * If set to FALSE, then $_GET will be set to an empty array.
64
+	 *
65
+	 * @var	bool
66
+	 */
67
+	protected $_allow_get_array = TRUE;
68
+
69
+	/**
70
+	 * Standardize new lines flag
71
+	 *
72
+	 * If set to TRUE, then newlines are standardized.
73
+	 *
74
+	 * @var	bool
75
+	 */
76
+	protected $_standardize_newlines;
77
+
78
+	/**
79
+	 * Enable XSS flag
80
+	 *
81
+	 * Determines whether the XSS filter is always active when
82
+	 * GET, POST or COOKIE data is encountered.
83
+	 * Set automatically based on config setting.
84
+	 *
85
+	 * @var	bool
86
+	 */
87
+	protected $_enable_xss = FALSE;
88
+
89
+	/**
90
+	 * Enable CSRF flag
91
+	 *
92
+	 * Enables a CSRF cookie token to be set.
93
+	 * Set automatically based on config setting.
94
+	 *
95
+	 * @var	bool
96
+	 */
97
+	protected $_enable_csrf = FALSE;
98
+
99
+	/**
100
+	 * List of all HTTP request headers
101
+	 *
102
+	 * @var array
103
+	 */
104
+	protected $headers = array();
105
+
106
+	/**
107
+	 * Raw input stream data
108
+	 *
109
+	 * Holds a cache of php://input contents
110
+	 *
111
+	 * @var	string
112
+	 */
113
+	protected $_raw_input_stream;
114
+
115
+	/**
116
+	 * Parsed input stream data
117
+	 *
118
+	 * Parsed from php://input at runtime
119
+	 *
120
+	 * @see	CI_Input::input_stream()
121
+	 * @var	array
122
+	 */
123
+	protected $_input_stream;
124
+
125
+	protected $security;
126
+	protected $uni;
127
+
128
+	// --------------------------------------------------------------------
129
+
130
+	/**
131
+	 * Class constructor
132
+	 *
133
+	 * Determines whether to globally enable the XSS processing
134
+	 * and whether to allow the $_GET array.
135
+	 *
136
+	 * @return	void
137
+	 */
138
+	public function __construct()
139
+	{
140
+		$this->_allow_get_array		= (config_item('allow_get_array') !== FALSE);
141
+		$this->_enable_xss		= (config_item('global_xss_filtering') === TRUE);
142
+		$this->_enable_csrf		= (config_item('csrf_protection') === TRUE);
143
+		$this->_standardize_newlines	= (bool) config_item('standardize_newlines');
144
+
145
+		$this->security =& load_class('Security', 'core');
146
+
147
+		// Do we need the UTF-8 class?
148
+		if (UTF8_ENABLED === TRUE)
149
+		{
150
+			$this->uni =& load_class('Utf8', 'core');
151
+		}
152
+
153
+		// Sanitize global arrays
154
+		$this->_sanitize_globals();
155
+
156
+		// CSRF Protection check
157
+		if ($this->_enable_csrf === TRUE && ! is_cli())
158
+		{
159
+			$this->security->csrf_verify();
160
+		}
161
+
162
+		log_message('info', 'Input Class Initialized');
163
+	}
164
+
165
+	// --------------------------------------------------------------------
166
+
167
+	/**
168
+	 * Fetch from array
169
+	 *
170
+	 * Internal method used to retrieve values from global arrays.
171
+	 *
172
+	 * @param	array	&$array		$_GET, $_POST, $_COOKIE, $_SERVER, etc.
173
+	 * @param	mixed	$index		Index for item to be fetched from $array
174
+	 * @param	bool	$xss_clean	Whether to apply XSS filtering
175
+	 * @return	mixed
176
+	 */
177
+	protected function _fetch_from_array(&$array, $index = NULL, $xss_clean = NULL)
178
+	{
179
+		is_bool($xss_clean) OR $xss_clean = $this->_enable_xss;
180
+
181
+		// If $index is NULL, it means that the whole $array is requested
182
+		isset($index) OR $index = array_keys($array);
183
+
184
+		// allow fetching multiple keys at once
185
+		if (is_array($index))
186
+		{
187
+			$output = array();
188
+			foreach ($index as $key)
189
+			{
190
+				$output[$key] = $this->_fetch_from_array($array, $key, $xss_clean);
191
+			}
192
+
193
+			return $output;
194
+		}
195
+
196
+		if (isset($array[$index]))
197
+		{
198
+			$value = $array[$index];
199
+		}
200
+		elseif (($count = preg_match_all('/(?:^[^\[]+)|\[[^]]*\]/', $index, $matches)) > 1) // Does the index contain array notation
201
+		{
202
+			$value = $array;
203
+			for ($i = 0; $i < $count; $i++)
204
+			{
205
+				$key = trim($matches[0][$i], '[]');
206
+				if ($key === '') // Empty notation will return the value as array
207
+				{
208
+					break;
209
+				}
210
+
211
+				if (isset($value[$key]))
212
+				{
213
+					$value = $value[$key];
214
+				}
215
+				else
216
+				{
217
+					return NULL;
218
+				}
219
+			}
220
+		}
221
+		else
222
+		{
223
+			return NULL;
224
+		}
225
+
226
+		return ($xss_clean === TRUE)
227
+			? $this->security->xss_clean($value)
228
+			: $value;
229
+	}
230
+
231
+	// --------------------------------------------------------------------
232
+
233
+	/**
234
+	 * Fetch an item from the GET array
235
+	 *
236
+	 * @param	mixed	$index		Index for item to be fetched from $_GET
237
+	 * @param	bool	$xss_clean	Whether to apply XSS filtering
238
+	 * @return	mixed
239
+	 */
240
+	public function get($index = NULL, $xss_clean = NULL)
241
+	{
242
+		return $this->_fetch_from_array($_GET, $index, $xss_clean);
243
+	}
244
+
245
+	// --------------------------------------------------------------------
246
+
247
+	/**
248
+	 * Fetch an item from the POST array
249
+	 *
250
+	 * @param	mixed	$index		Index for item to be fetched from $_POST
251
+	 * @param	bool	$xss_clean	Whether to apply XSS filtering
252
+	 * @return	mixed
253
+	 */
254
+	public function post($index = NULL, $xss_clean = NULL)
255
+	{
256
+		return $this->_fetch_from_array($_POST, $index, $xss_clean);
257
+	}
258
+
259
+	// --------------------------------------------------------------------
260
+
261
+	/**
262
+	 * Fetch an item from POST data with fallback to GET
263
+	 *
264
+	 * @param	string	$index		Index for item to be fetched from $_POST or $_GET
265
+	 * @param	bool	$xss_clean	Whether to apply XSS filtering
266
+	 * @return	mixed
267
+	 */
268
+	public function post_get($index, $xss_clean = NULL)
269
+	{
270
+		return isset($_POST[$index])
271
+			? $this->post($index, $xss_clean)
272
+			: $this->get($index, $xss_clean);
273
+	}
274
+
275
+	// --------------------------------------------------------------------
276
+
277
+	/**
278
+	 * Fetch an item from GET data with fallback to POST
279
+	 *
280
+	 * @param	string	$index		Index for item to be fetched from $_GET or $_POST
281
+	 * @param	bool	$xss_clean	Whether to apply XSS filtering
282
+	 * @return	mixed
283
+	 */
284
+	public function get_post($index, $xss_clean = NULL)
285
+	{
286
+		return isset($_GET[$index])
287
+			? $this->get($index, $xss_clean)
288
+			: $this->post($index, $xss_clean);
289
+	}
290
+
291
+	// --------------------------------------------------------------------
292
+
293
+	/**
294
+	 * Fetch an item from the COOKIE array
295
+	 *
296
+	 * @param	mixed	$index		Index for item to be fetched from $_COOKIE
297
+	 * @param	bool	$xss_clean	Whether to apply XSS filtering
298
+	 * @return	mixed
299
+	 */
300
+	public function cookie($index = NULL, $xss_clean = NULL)
301
+	{
302
+		return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
303
+	}
304
+
305
+	// --------------------------------------------------------------------
306
+
307
+	/**
308
+	 * Fetch an item from the SERVER array
309
+	 *
310
+	 * @param	mixed	$index		Index for item to be fetched from $_SERVER
311
+	 * @param	bool	$xss_clean	Whether to apply XSS filtering
312
+	 * @return	mixed
313
+	 */
314
+	public function server($index, $xss_clean = NULL)
315
+	{
316
+		return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
317
+	}
318
+
319
+	// ------------------------------------------------------------------------
320
+
321
+	/**
322
+	 * Fetch an item from the php://input stream
323
+	 *
324
+	 * Useful when you need to access PUT, DELETE or PATCH request data.
325
+	 *
326
+	 * @param	string	$index		Index for item to be fetched
327
+	 * @param	bool	$xss_clean	Whether to apply XSS filtering
328
+	 * @return	mixed
329
+	 */
330
+	public function input_stream($index = NULL, $xss_clean = NULL)
331
+	{
332
+		// Prior to PHP 5.6, the input stream can only be read once,
333
+		// so we'll need to check if we have already done that first.
334
+		if ( ! is_array($this->_input_stream))
335
+		{
336
+			// $this->raw_input_stream will trigger __get().
337
+			parse_str($this->raw_input_stream, $this->_input_stream);
338
+			is_array($this->_input_stream) OR $this->_input_stream = array();
339
+		}
340
+
341
+		return $this->_fetch_from_array($this->_input_stream, $index, $xss_clean);
342
+	}
343
+
344
+	// ------------------------------------------------------------------------
345
+
346
+	/**
347
+	 * Set cookie
348
+	 *
349
+	 * Accepts an arbitrary number of parameters (up to 7) or an associative
350
+	 * array in the first parameter containing all the values.
351
+	 *
352
+	 * @param	string|mixed[]	$name		Cookie name or an array containing parameters
353
+	 * @param	string		$value		Cookie value
354
+	 * @param	int		$expire		Cookie expiration time in seconds
355
+	 * @param	string		$domain		Cookie domain (e.g.: '.yourdomain.com')
356
+	 * @param	string		$path		Cookie path (default: '/')
357
+	 * @param	string		$prefix		Cookie name prefix
358
+	 * @param	bool		$secure		Whether to only transfer cookies via SSL
359
+	 * @param	bool		$httponly	Whether to only makes the cookie accessible via HTTP (no javascript)
360
+	 * @return	void
361
+	 */
362
+	public function set_cookie($name, $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = NULL, $httponly = NULL)
363
+	{
364
+		if (is_array($name))
365
+		{
366
+			// always leave 'name' in last place, as the loop will break otherwise, due to $$item
367
+			foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name') as $item)
368
+			{
369
+				if (isset($name[$item]))
370
+				{
371
+					$$item = $name[$item];
372
+				}
373
+			}
374
+		}
375
+
376
+		if ($prefix === '' && config_item('cookie_prefix') !== '')
377
+		{
378
+			$prefix = config_item('cookie_prefix');
379
+		}
380
+
381
+		if ($domain == '' && config_item('cookie_domain') != '')
382
+		{
383
+			$domain = config_item('cookie_domain');
384
+		}
385
+
386
+		if ($path === '/' && config_item('cookie_path') !== '/')
387
+		{
388
+			$path = config_item('cookie_path');
389
+		}
390
+
391
+		$secure = ($secure === NULL && config_item('cookie_secure') !== NULL)
392
+			? (bool) config_item('cookie_secure')
393
+			: (bool) $secure;
394
+
395
+		$httponly = ($httponly === NULL && config_item('cookie_httponly') !== NULL)
396
+			? (bool) config_item('cookie_httponly')
397
+			: (bool) $httponly;
398
+
399
+		if ( ! is_numeric($expire))
400
+		{
401
+			$expire = time() - 86500;
402
+		}
403
+		else
404
+		{
405
+			$expire = ($expire > 0) ? time() + $expire : 0;
406
+		}
407
+
408
+		setcookie($prefix.$name, $value, $expire, $path, $domain, $secure, $httponly);
409
+	}
410
+
411
+	// --------------------------------------------------------------------
412
+
413
+	/**
414
+	 * Fetch the IP Address
415
+	 *
416
+	 * Determines and validates the visitor's IP address.
417
+	 *
418
+	 * @return	string	IP address
419
+	 */
420
+	public function ip_address()
421
+	{
422
+		if ($this->ip_address !== FALSE)
423
+		{
424
+			return $this->ip_address;
425
+		}
426
+
427
+		$proxy_ips = config_item('proxy_ips');
428
+		if ( ! empty($proxy_ips) && ! is_array($proxy_ips))
429
+		{
430
+			$proxy_ips = explode(',', str_replace(' ', '', $proxy_ips));
431
+		}
432
+
433
+		$this->ip_address = $this->server('REMOTE_ADDR');
434
+
435
+		if ($proxy_ips)
436
+		{
437
+			foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP') as $header)
438
+			{
439
+				if (($spoof = $this->server($header)) !== NULL)
440
+				{
441
+					// Some proxies typically list the whole chain of IP
442
+					// addresses through which the client has reached us.
443
+					// e.g. client_ip, proxy_ip1, proxy_ip2, etc.
444
+					sscanf($spoof, '%[^,]', $spoof);
445
+
446
+					if ( ! $this->valid_ip($spoof))
447
+					{
448
+						$spoof = NULL;
449
+					}
450
+					else
451
+					{
452
+						break;
453
+					}
454
+				}
455
+			}
456
+
457
+			if ($spoof)
458
+			{
459
+				for ($i = 0, $c = count($proxy_ips); $i < $c; $i++)
460
+				{
461
+					// Check if we have an IP address or a subnet
462
+					if (strpos($proxy_ips[$i], '/') === FALSE)
463
+					{
464
+						// An IP address (and not a subnet) is specified.
465
+						// We can compare right away.
466
+						if ($proxy_ips[$i] === $this->ip_address)
467
+						{
468
+							$this->ip_address = $spoof;
469
+							break;
470
+						}
471
+
472
+						continue;
473
+					}
474
+
475
+					// We have a subnet ... now the heavy lifting begins
476
+					isset($separator) OR $separator = $this->valid_ip($this->ip_address, 'ipv6') ? ':' : '.';
477
+
478
+					// If the proxy entry doesn't match the IP protocol - skip it
479
+					if (strpos($proxy_ips[$i], $separator) === FALSE)
480
+					{
481
+						continue;
482
+					}
483
+
484
+					// Convert the REMOTE_ADDR IP address to binary, if needed
485
+					if ( ! isset($ip, $sprintf))
486
+					{
487
+						if ($separator === ':')
488
+						{
489
+							// Make sure we're have the "full" IPv6 format
490
+							$ip = explode(':',
491
+								str_replace('::',
492
+									str_repeat(':', 9 - substr_count($this->ip_address, ':')),
493
+									$this->ip_address
494
+								)
495
+							);
496
+
497
+							for ($j = 0; $j < 8; $j++)
498
+							{
499
+								$ip[$j] = intval($ip[$j], 16);
500
+							}
501
+
502
+							$sprintf = '%016b%016b%016b%016b%016b%016b%016b%016b';
503
+						}
504
+						else
505
+						{
506
+							$ip = explode('.', $this->ip_address);
507
+							$sprintf = '%08b%08b%08b%08b';
508
+						}
509
+
510
+						$ip = vsprintf($sprintf, $ip);
511
+					}
512
+
513
+					// Split the netmask length off the network address
514
+					sscanf($proxy_ips[$i], '%[^/]/%d', $netaddr, $masklen);
515
+
516
+					// Again, an IPv6 address is most likely in a compressed form
517
+					if ($separator === ':')
518
+					{
519
+						$netaddr = explode(':', str_replace('::', str_repeat(':', 9 - substr_count($netaddr, ':')), $netaddr));
520
+						for ($j = 0; $j < 8; $j++)
521
+						{
522
+							$netaddr[$j] = intval($netaddr[$j], 16);
523
+						}
524
+					}
525
+					else
526
+					{
527
+						$netaddr = explode('.', $netaddr);
528
+					}
529
+
530
+					// Convert to binary and finally compare
531
+					if (strncmp($ip, vsprintf($sprintf, $netaddr), $masklen) === 0)
532
+					{
533
+						$this->ip_address = $spoof;
534
+						break;
535
+					}
536
+				}
537
+			}
538
+		}
539
+
540
+		if ( ! $this->valid_ip($this->ip_address))
541
+		{
542
+			return $this->ip_address = '0.0.0.0';
543
+		}
544
+
545
+		return $this->ip_address;
546
+	}
547
+
548
+	// --------------------------------------------------------------------
549
+
550
+	/**
551
+	 * Validate IP Address
552
+	 *
553
+	 * @param	string	$ip	IP address
554
+	 * @param	string	$which	IP protocol: 'ipv4' or 'ipv6'
555
+	 * @return	bool
556
+	 */
557
+	public function valid_ip($ip, $which = '')
558
+	{
559
+		switch (strtolower($which))
560
+		{
561
+			case 'ipv4':
562
+				$which = FILTER_FLAG_IPV4;
563
+				break;
564
+			case 'ipv6':
565
+				$which = FILTER_FLAG_IPV6;
566
+				break;
567
+			default:
568
+				$which = NULL;
569
+				break;
570
+		}
571
+
572
+		return (bool) filter_var($ip, FILTER_VALIDATE_IP, $which);
573
+	}
574
+
575
+	// --------------------------------------------------------------------
576
+
577
+	/**
578
+	 * Fetch User Agent string
579
+	 *
580
+	 * @return	string|null	User Agent string or NULL if it doesn't exist
581
+	 */
582
+	public function user_agent($xss_clean = NULL)
583
+	{
584
+		return $this->_fetch_from_array($_SERVER, 'HTTP_USER_AGENT', $xss_clean);
585
+	}
586
+
587
+	// --------------------------------------------------------------------
588
+
589
+	/**
590
+	 * Sanitize Globals
591
+	 *
592
+	 * Internal method serving for the following purposes:
593
+	 *
594
+	 *	- Unsets $_GET data, if query strings are not enabled
595
+	 *	- Cleans POST, COOKIE and SERVER data
596
+	 * 	- Standardizes newline characters to PHP_EOL
597
+	 *
598
+	 * @return	void
599
+	 */
600
+	protected function _sanitize_globals()
601
+	{
602
+		// Is $_GET data allowed? If not we'll set the $_GET to an empty array
603
+		if ($this->_allow_get_array === FALSE)
604
+		{
605
+			$_GET = array();
606
+		}
607
+		elseif (is_array($_GET))
608
+		{
609
+			foreach ($_GET as $key => $val)
610
+			{
611
+				$_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
612
+			}
613
+		}
614
+
615
+		// Clean $_POST Data
616
+		if (is_array($_POST))
617
+		{
618
+			foreach ($_POST as $key => $val)
619
+			{
620
+				$_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
621
+			}
622
+		}
623
+
624
+		// Clean $_COOKIE Data
625
+		if (is_array($_COOKIE))
626
+		{
627
+			// Also get rid of specially treated cookies that might be set by a server
628
+			// or silly application, that are of no use to a CI application anyway
629
+			// but that when present will trip our 'Disallowed Key Characters' alarm
630
+			// http://www.ietf.org/rfc/rfc2109.txt
631
+			// note that the key names below are single quoted strings, and are not PHP variables
632
+			unset(
633
+				$_COOKIE['$Version'],
634
+				$_COOKIE['$Path'],
635
+				$_COOKIE['$Domain']
636
+			);
637
+
638
+			foreach ($_COOKIE as $key => $val)
639
+			{
640
+				if (($cookie_key = $this->_clean_input_keys($key)) !== FALSE)
641
+				{
642
+					$_COOKIE[$cookie_key] = $this->_clean_input_data($val);
643
+				}
644
+				else
645
+				{
646
+					unset($_COOKIE[$key]);
647
+				}
648
+			}
649
+		}
650
+
651
+		// Sanitize PHP_SELF
652
+		$_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
653
+
654
+		log_message('debug', 'Global POST, GET and COOKIE data sanitized');
655
+	}
656
+
657
+	// --------------------------------------------------------------------
658
+
659
+	/**
660
+	 * Clean Input Data
661
+	 *
662
+	 * Internal method that aids in escaping data and
663
+	 * standardizing newline characters to PHP_EOL.
664
+	 *
665
+	 * @param	string|string[]	$str	Input string(s)
666
+	 * @return	string
667
+	 */
668
+	protected function _clean_input_data($str)
669
+	{
670
+		if (is_array($str))
671
+		{
672
+			$new_array = array();
673
+			foreach (array_keys($str) as $key)
674
+			{
675
+				$new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($str[$key]);
676
+			}
677
+			return $new_array;
678
+		}
679
+
680
+		/* We strip slashes if magic quotes is on to keep things consistent
681
+
682
+		   NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
683
+		         it will probably not exist in future versions at all.
684
+		*/
685
+		if ( ! is_php('5.4') && get_magic_quotes_gpc())
686
+		{
687
+			$str = stripslashes($str);
688
+		}
689
+
690
+		// Clean UTF-8 if supported
691
+		if (UTF8_ENABLED === TRUE)
692
+		{
693
+			$str = $this->uni->clean_string($str);
694
+		}
695
+
696
+		// Remove control characters
697
+		$str = remove_invisible_characters($str, FALSE);
698
+
699
+		// Standardize newlines if needed
700
+		if ($this->_standardize_newlines === TRUE)
701
+		{
702
+			return preg_replace('/(?:\r\n|[\r\n])/', PHP_EOL, $str);
703
+		}
704
+
705
+		return $str;
706
+	}
707
+
708
+	// --------------------------------------------------------------------
709
+
710
+	/**
711
+	 * Clean Keys
712
+	 *
713
+	 * Internal method that helps to prevent malicious users
714
+	 * from trying to exploit keys we make sure that keys are
715
+	 * only named with alpha-numeric text and a few other items.
716
+	 *
717
+	 * @param	string	$str	Input string
718
+	 * @param	bool	$fatal	Whether to terminate script exection
719
+	 *				or to return FALSE if an invalid
720
+	 *				key is encountered
721
+	 * @return	string|bool
722
+	 */
723
+	protected function _clean_input_keys($str, $fatal = TRUE)
724
+	{
725
+		if ( ! preg_match('/^[a-z0-9:_\/|-]+$/i', $str))
726
+		{
727
+			if ($fatal === TRUE)
728
+			{
729
+				return FALSE;
730
+			}
731
+			else
732
+			{
733
+				set_status_header(503);
734
+				echo 'Disallowed Key Characters.';
735
+				exit(7); // EXIT_USER_INPUT
736
+			}
737
+		}
738
+
739
+		// Clean UTF-8 if supported
740
+		if (UTF8_ENABLED === TRUE)
741
+		{
742
+			return $this->uni->clean_string($str);
743
+		}
744
+
745
+		return $str;
746
+	}
747
+
748
+	// --------------------------------------------------------------------
749
+
750
+	/**
751
+	 * Request Headers
752
+	 *
753
+	 * @param	bool	$xss_clean	Whether to apply XSS filtering
754
+	 * @return	array
755
+	 */
756
+	public function request_headers($xss_clean = FALSE)
757
+	{
758
+		// If header is already defined, return it immediately
759
+		if ( ! empty($this->headers))
760
+		{
761
+			return $this->_fetch_from_array($this->headers, NULL, $xss_clean);
762
+		}
763
+
764
+		// In Apache, you can simply call apache_request_headers()
765
+		if (function_exists('apache_request_headers'))
766
+		{
767
+			$this->headers = apache_request_headers();
768
+		}
769
+		else
770
+		{
771
+			isset($_SERVER['CONTENT_TYPE']) && $this->headers['Content-Type'] = $_SERVER['CONTENT_TYPE'];
772
+
773
+			foreach ($_SERVER as $key => $val)
774
+			{
775
+				if (sscanf($key, 'HTTP_%s', $header) === 1)
776
+				{
777
+					// take SOME_HEADER and turn it into Some-Header
778
+					$header = str_replace('_', ' ', strtolower($header));
779
+					$header = str_replace(' ', '-', ucwords($header));
780
+
781
+					$this->headers[$header] = $_SERVER[$key];
782
+				}
783
+			}
784
+		}
785
+
786
+		return $this->_fetch_from_array($this->headers, NULL, $xss_clean);
787
+	}
788
+
789
+	// --------------------------------------------------------------------
790
+
791
+	/**
792
+	 * Get Request Header
793
+	 *
794
+	 * Returns the value of a single member of the headers class member
795
+	 *
796
+	 * @param	string		$index		Header name
797
+	 * @param	bool		$xss_clean	Whether to apply XSS filtering
798
+	 * @return	string|null	The requested header on success or NULL on failure
799
+	 */
800
+	public function get_request_header($index, $xss_clean = FALSE)
801
+	{
802
+		static $headers;
803
+
804
+		if ( ! isset($headers))
805
+		{
806
+			empty($this->headers) && $this->request_headers();
807
+			foreach ($this->headers as $key => $value)
808
+			{
809
+				$headers[strtolower($key)] = $value;
810
+			}
811
+		}
812
+
813
+		$index = strtolower($index);
814
+
815
+		if ( ! isset($headers[$index]))
816
+		{
817
+			return NULL;
818
+		}
819
+
820
+		return ($xss_clean === TRUE)
821
+			? $this->security->xss_clean($headers[$index])
822
+			: $headers[$index];
823
+	}
824
+
825
+	// --------------------------------------------------------------------
826
+
827
+	/**
828
+	 * Is AJAX request?
829
+	 *
830
+	 * Test to see if a request contains the HTTP_X_REQUESTED_WITH header.
831
+	 *
832
+	 * @return 	bool
833
+	 */
834
+	public function is_ajax_request()
835
+	{
836
+		return ( ! empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
837
+	}
838
+
839
+	// --------------------------------------------------------------------
840
+
841
+	/**
842
+	 * Is CLI request?
843
+	 *
844
+	 * Test to see if a request was made from the command line.
845
+	 *
846
+	 * @deprecated	3.0.0	Use is_cli() instead
847
+	 * @return	bool
848
+	 */
849
+	public function is_cli_request()
850
+	{
851
+		return is_cli();
852
+	}
853
+
854
+	// --------------------------------------------------------------------
855
+
856
+	/**
857
+	 * Get Request Method
858
+	 *
859
+	 * Return the request method
860
+	 *
861
+	 * @param	bool	$upper	Whether to return in upper or lower case
862
+	 *				(default: FALSE)
863
+	 * @return 	string
864
+	 */
865
+	public function method($upper = FALSE)
866
+	{
867
+		return ($upper)
868
+			? strtoupper($this->server('REQUEST_METHOD'))
869
+			: strtolower($this->server('REQUEST_METHOD'));
870
+	}
871
+
872
+	// ------------------------------------------------------------------------
873
+
874
+	/**
875
+	 * Magic __get()
876
+	 *
877
+	 * Allows read access to protected properties
878
+	 *
879
+	 * @param	string	$name
880
+	 * @return	mixed
881
+	 */
882
+	public function __get($name)
883
+	{
884
+		if ($name === 'raw_input_stream')
885
+		{
886
+			isset($this->_raw_input_stream) OR $this->_raw_input_stream = file_get_contents('php://input');
887
+			return $this->_raw_input_stream;
888
+		}
889
+		elseif ($name === 'ip_address')
890
+		{
891
+			return $this->ip_address;
892
+		}
893
+	}
894
+
895
+}

+ 203 - 0
system/core/Lang.php Datei anzeigen

@@ -0,0 +1,203 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Language Class
42
+ *
43
+ * @package		CodeIgniter
44
+ * @subpackage	Libraries
45
+ * @category	Language
46
+ * @author		EllisLab Dev Team
47
+ * @link		https://codeigniter.com/user_guide/libraries/language.html
48
+ */
49
+class CI_Lang {
50
+
51
+	/**
52
+	 * List of translations
53
+	 *
54
+	 * @var	array
55
+	 */
56
+	public $language =	array();
57
+
58
+	/**
59
+	 * List of loaded language files
60
+	 *
61
+	 * @var	array
62
+	 */
63
+	public $is_loaded =	array();
64
+
65
+	/**
66
+	 * Class constructor
67
+	 *
68
+	 * @return	void
69
+	 */
70
+	public function __construct()
71
+	{
72
+		log_message('info', 'Language Class Initialized');
73
+	}
74
+
75
+	// --------------------------------------------------------------------
76
+
77
+	/**
78
+	 * Load a language file
79
+	 *
80
+	 * @param	mixed	$langfile	Language file name
81
+	 * @param	string	$idiom		Language name (english, etc.)
82
+	 * @param	bool	$return		Whether to return the loaded array of translations
83
+	 * @param 	bool	$add_suffix	Whether to add suffix to $langfile
84
+	 * @param 	string	$alt_path	Alternative path to look for the language file
85
+	 *
86
+	 * @return	void|string[]	Array containing translations, if $return is set to TRUE
87
+	 */
88
+	public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
89
+	{
90
+		if (is_array($langfile))
91
+		{
92
+			foreach ($langfile as $value)
93
+			{
94
+				$this->load($value, $idiom, $return, $add_suffix, $alt_path);
95
+			}
96
+
97
+			return;
98
+		}
99
+
100
+		$langfile = str_replace('.php', '', $langfile);
101
+
102
+		if ($add_suffix === TRUE)
103
+		{
104
+			$langfile = preg_replace('/_lang$/', '', $langfile).'_lang';
105
+		}
106
+
107
+		$langfile .= '.php';
108
+
109
+		if (empty($idiom) OR ! preg_match('/^[a-z_-]+$/i', $idiom))
110
+		{
111
+			$config =& get_config();
112
+			$idiom = empty($config['language']) ? 'english' : $config['language'];
113
+		}
114
+
115
+		if ($return === FALSE && isset($this->is_loaded[$langfile]) && $this->is_loaded[$langfile] === $idiom)
116
+		{
117
+			return;
118
+		}
119
+
120
+		// Load the base file, so any others found can override it
121
+		$basepath = BASEPATH.'language/'.$idiom.'/'.$langfile;
122
+		if (($found = file_exists($basepath)) === TRUE)
123
+		{
124
+			include($basepath);
125
+		}
126
+
127
+		// Do we have an alternative path to look in?
128
+		if ($alt_path !== '')
129
+		{
130
+			$alt_path .= 'language/'.$idiom.'/'.$langfile;
131
+			if (file_exists($alt_path))
132
+			{
133
+				include($alt_path);
134
+				$found = TRUE;
135
+			}
136
+		}
137
+		else
138
+		{
139
+			foreach (get_instance()->load->get_package_paths(TRUE) as $package_path)
140
+			{
141
+				$package_path .= 'language/'.$idiom.'/'.$langfile;
142
+				if ($basepath !== $package_path && file_exists($package_path))
143
+				{
144
+					include($package_path);
145
+					$found = TRUE;
146
+					break;
147
+				}
148
+			}
149
+		}
150
+
151
+		if ($found !== TRUE)
152
+		{
153
+			show_error('Unable to load the requested language file: language/'.$idiom.'/'.$langfile);
154
+		}
155
+
156
+		if ( ! isset($lang) OR ! is_array($lang))
157
+		{
158
+			log_message('error', 'Language file contains no data: language/'.$idiom.'/'.$langfile);
159
+
160
+			if ($return === TRUE)
161
+			{
162
+				return array();
163
+			}
164
+			return;
165
+		}
166
+
167
+		if ($return === TRUE)
168
+		{
169
+			return $lang;
170
+		}
171
+
172
+		$this->is_loaded[$langfile] = $idiom;
173
+		$this->language = array_merge($this->language, $lang);
174
+
175
+		log_message('info', 'Language file loaded: language/'.$idiom.'/'.$langfile);
176
+		return TRUE;
177
+	}
178
+
179
+	// --------------------------------------------------------------------
180
+
181
+	/**
182
+	 * Language line
183
+	 *
184
+	 * Fetches a single line of text from the language array
185
+	 *
186
+	 * @param	string	$line		Language line key
187
+	 * @param	bool	$log_errors	Whether to log an error message if the line is not found
188
+	 * @return	string	Translation
189
+	 */
190
+	public function line($line, $log_errors = TRUE)
191
+	{
192
+		$value = isset($this->language[$line]) ? $this->language[$line] : FALSE;
193
+
194
+		// Because killer robots like unicorns!
195
+		if ($value === FALSE && $log_errors === TRUE)
196
+		{
197
+			log_message('error', 'Could not find the language line "'.$line.'"');
198
+		}
199
+
200
+		return $value;
201
+	}
202
+
203
+}

Datei-Diff unterdrückt, da er zu groß ist
+ 1415 - 0
system/core/Loader.php


+ 296 - 0
system/core/Log.php Datei anzeigen

@@ -0,0 +1,296 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Logging Class
42
+ *
43
+ * @package		CodeIgniter
44
+ * @subpackage	Libraries
45
+ * @category	Logging
46
+ * @author		EllisLab Dev Team
47
+ * @link		https://codeigniter.com/user_guide/general/errors.html
48
+ */
49
+class CI_Log {
50
+
51
+	/**
52
+	 * Path to save log files
53
+	 *
54
+	 * @var string
55
+	 */
56
+	protected $_log_path;
57
+
58
+	/**
59
+	 * File permissions
60
+	 *
61
+	 * @var	int
62
+	 */
63
+	protected $_file_permissions = 0644;
64
+
65
+	/**
66
+	 * Level of logging
67
+	 *
68
+	 * @var int
69
+	 */
70
+	protected $_threshold = 1;
71
+
72
+	/**
73
+	 * Array of threshold levels to log
74
+	 *
75
+	 * @var array
76
+	 */
77
+	protected $_threshold_array = array();
78
+
79
+	/**
80
+	 * Format of timestamp for log files
81
+	 *
82
+	 * @var string
83
+	 */
84
+	protected $_date_fmt = 'Y-m-d H:i:s';
85
+
86
+	/**
87
+	 * Filename extension
88
+	 *
89
+	 * @var	string
90
+	 */
91
+	protected $_file_ext;
92
+
93
+	/**
94
+	 * Whether or not the logger can write to the log files
95
+	 *
96
+	 * @var bool
97
+	 */
98
+	protected $_enabled = TRUE;
99
+
100
+	/**
101
+	 * Predefined logging levels
102
+	 *
103
+	 * @var array
104
+	 */
105
+	protected $_levels = array('ERROR' => 1, 'DEBUG' => 2, 'INFO' => 3, 'ALL' => 4);
106
+
107
+	/**
108
+	 * mbstring.func_overload flag
109
+	 *
110
+	 * @var	bool
111
+	 */
112
+	protected static $func_overload;
113
+
114
+	// --------------------------------------------------------------------
115
+
116
+	/**
117
+	 * Class constructor
118
+	 *
119
+	 * @return	void
120
+	 */
121
+	public function __construct()
122
+	{
123
+		$config =& get_config();
124
+
125
+		isset(self::$func_overload) OR self::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
126
+
127
+		$this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/';
128
+		$this->_file_ext = (isset($config['log_file_extension']) && $config['log_file_extension'] !== '')
129
+			? ltrim($config['log_file_extension'], '.') : 'php';
130
+
131
+		file_exists($this->_log_path) OR mkdir($this->_log_path, 0755, TRUE);
132
+
133
+		if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path))
134
+		{
135
+			$this->_enabled = FALSE;
136
+		}
137
+
138
+		if (is_numeric($config['log_threshold']))
139
+		{
140
+			$this->_threshold = (int) $config['log_threshold'];
141
+		}
142
+		elseif (is_array($config['log_threshold']))
143
+		{
144
+			$this->_threshold = 0;
145
+			$this->_threshold_array = array_flip($config['log_threshold']);
146
+		}
147
+
148
+		if ( ! empty($config['log_date_format']))
149
+		{
150
+			$this->_date_fmt = $config['log_date_format'];
151
+		}
152
+
153
+		if ( ! empty($config['log_file_permissions']) && is_int($config['log_file_permissions']))
154
+		{
155
+			$this->_file_permissions = $config['log_file_permissions'];
156
+		}
157
+	}
158
+
159
+	// --------------------------------------------------------------------
160
+
161
+	/**
162
+	 * Write Log File
163
+	 *
164
+	 * Generally this function will be called using the global log_message() function
165
+	 *
166
+	 * @param	string	$level 	The error level: 'error', 'debug' or 'info'
167
+	 * @param	string	$msg 	The error message
168
+	 * @return	bool
169
+	 */
170
+	public function write_log($level, $msg)
171
+	{
172
+		if ($this->_enabled === FALSE)
173
+		{
174
+			return FALSE;
175
+		}
176
+
177
+		$level = strtoupper($level);
178
+
179
+		if (( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
180
+			&& ! isset($this->_threshold_array[$this->_levels[$level]]))
181
+		{
182
+			return FALSE;
183
+		}
184
+
185
+		$filepath = $this->_log_path.'log-'.date('Y-m-d').'.'.$this->_file_ext;
186
+		$message = '';
187
+
188
+		if ( ! file_exists($filepath))
189
+		{
190
+			$newfile = TRUE;
191
+			// Only add protection to php files
192
+			if ($this->_file_ext === 'php')
193
+			{
194
+				$message .= "<?php defined('BASEPATH') OR exit('No direct script access allowed'); ?>\n\n";
195
+			}
196
+		}
197
+
198
+		if ( ! $fp = @fopen($filepath, 'ab'))
199
+		{
200
+			return FALSE;
201
+		}
202
+
203
+		flock($fp, LOCK_EX);
204
+
205
+		// Instantiating DateTime with microseconds appended to initial date is needed for proper support of this format
206
+		if (strpos($this->_date_fmt, 'u') !== FALSE)
207
+		{
208
+			$microtime_full = microtime(TRUE);
209
+			$microtime_short = sprintf("%06d", ($microtime_full - floor($microtime_full)) * 1000000);
210
+			$date = new DateTime(date('Y-m-d H:i:s.'.$microtime_short, $microtime_full));
211
+			$date = $date->format($this->_date_fmt);
212
+		}
213
+		else
214
+		{
215
+			$date = date($this->_date_fmt);
216
+		}
217
+
218
+		$message .= $this->_format_line($level, $date, $msg);
219
+
220
+		for ($written = 0, $length = self::strlen($message); $written < $length; $written += $result)
221
+		{
222
+			if (($result = fwrite($fp, self::substr($message, $written))) === FALSE)
223
+			{
224
+				break;
225
+			}
226
+		}
227
+
228
+		flock($fp, LOCK_UN);
229
+		fclose($fp);
230
+
231
+		if (isset($newfile) && $newfile === TRUE)
232
+		{
233
+			chmod($filepath, $this->_file_permissions);
234
+		}
235
+
236
+		return is_int($result);
237
+	}
238
+
239
+	// --------------------------------------------------------------------
240
+
241
+	/**
242
+	 * Format the log line.
243
+	 *
244
+	 * This is for extensibility of log formatting
245
+	 * If you want to change the log format, extend the CI_Log class and override this method
246
+	 *
247
+	 * @param	string	$level 	The error level
248
+	 * @param	string	$date 	Formatted date string
249
+	 * @param	string	$message 	The log message
250
+	 * @return	string	Formatted log line with a new line character at the end
251
+	 */
252
+	protected function _format_line($level, $date, $message)
253
+	{
254
+		return $level.' - '.$date.' --> '.$message.PHP_EOL;
255
+	}
256
+
257
+	// --------------------------------------------------------------------
258
+
259
+	/**
260
+	 * Byte-safe strlen()
261
+	 *
262
+	 * @param	string	$str
263
+	 * @return	int
264
+	 */
265
+	protected static function strlen($str)
266
+	{
267
+		return (self::$func_overload)
268
+			? mb_strlen($str, '8bit')
269
+			: strlen($str);
270
+	}
271
+
272
+	// --------------------------------------------------------------------
273
+
274
+	/**
275
+	 * Byte-safe substr()
276
+	 *
277
+	 * @param	string	$str
278
+	 * @param	int	$start
279
+	 * @param	int	$length
280
+	 * @return	string
281
+	 */
282
+	protected static function substr($str, $start, $length = NULL)
283
+	{
284
+		if (self::$func_overload)
285
+		{
286
+			// mb_substr($str, $start, null, '8bit') returns an empty
287
+			// string on PHP 5.3
288
+			isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
289
+			return mb_substr($str, $start, $length, '8bit');
290
+		}
291
+
292
+		return isset($length)
293
+			? substr($str, $start, $length)
294
+			: substr($str, $start);
295
+	}
296
+}

+ 76 - 0
system/core/Model.php Datei anzeigen

@@ -0,0 +1,76 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Model Class
42
+ *
43
+ * @package		CodeIgniter
44
+ * @subpackage	Libraries
45
+ * @category	Libraries
46
+ * @author		EllisLab Dev Team
47
+ * @link		https://codeigniter.com/user_guide/libraries/config.html
48
+ */
49
+class CI_Model {
50
+
51
+	/**
52
+	 * Class constructor
53
+	 *
54
+	 * @link	https://github.com/bcit-ci/CodeIgniter/issues/5332
55
+	 * @return	void
56
+	 */
57
+	public function __construct() {}
58
+
59
+	/**
60
+	 * __get magic
61
+	 *
62
+	 * Allows models to access CI's loaded classes using the same
63
+	 * syntax as controllers.
64
+	 *
65
+	 * @param	string	$key
66
+	 */
67
+	public function __get($key)
68
+	{
69
+		// Debugging note:
70
+		//	If you're here because you're getting an error message
71
+		//	saying 'Undefined Property: system/core/Model.php', it's
72
+		//	most likely a typo in your model code.
73
+		return get_instance()->$key;
74
+	}
75
+
76
+}

+ 842 - 0
system/core/Output.php Datei anzeigen

@@ -0,0 +1,842 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Output Class
42
+ *
43
+ * Responsible for sending final output to the browser.
44
+ *
45
+ * @package		CodeIgniter
46
+ * @subpackage	Libraries
47
+ * @category	Output
48
+ * @author		EllisLab Dev Team
49
+ * @link		https://codeigniter.com/user_guide/libraries/output.html
50
+ */
51
+class CI_Output {
52
+
53
+	/**
54
+	 * Final output string
55
+	 *
56
+	 * @var	string
57
+	 */
58
+	public $final_output;
59
+
60
+	/**
61
+	 * Cache expiration time
62
+	 *
63
+	 * @var	int
64
+	 */
65
+	public $cache_expiration = 0;
66
+
67
+	/**
68
+	 * List of server headers
69
+	 *
70
+	 * @var	array
71
+	 */
72
+	public $headers = array();
73
+
74
+	/**
75
+	 * List of mime types
76
+	 *
77
+	 * @var	array
78
+	 */
79
+	public $mimes =	array();
80
+
81
+	/**
82
+	 * Mime-type for the current page
83
+	 *
84
+	 * @var	string
85
+	 */
86
+	protected $mime_type = 'text/html';
87
+
88
+	/**
89
+	 * Enable Profiler flag
90
+	 *
91
+	 * @var	bool
92
+	 */
93
+	public $enable_profiler = FALSE;
94
+
95
+	/**
96
+	 * php.ini zlib.output_compression flag
97
+	 *
98
+	 * @var	bool
99
+	 */
100
+	protected $_zlib_oc = FALSE;
101
+
102
+	/**
103
+	 * CI output compression flag
104
+	 *
105
+	 * @var	bool
106
+	 */
107
+	protected $_compress_output = FALSE;
108
+
109
+	/**
110
+	 * List of profiler sections
111
+	 *
112
+	 * @var	array
113
+	 */
114
+	protected $_profiler_sections =	array();
115
+
116
+	/**
117
+	 * Parse markers flag
118
+	 *
119
+	 * Whether or not to parse variables like {elapsed_time} and {memory_usage}.
120
+	 *
121
+	 * @var	bool
122
+	 */
123
+	public $parse_exec_vars = TRUE;
124
+
125
+	/**
126
+	 * mbstring.func_overload flag
127
+	 *
128
+	 * @var	bool
129
+	 */
130
+	protected static $func_overload;
131
+
132
+	/**
133
+	 * Class constructor
134
+	 *
135
+	 * Determines whether zLib output compression will be used.
136
+	 *
137
+	 * @return	void
138
+	 */
139
+	public function __construct()
140
+	{
141
+		$this->_zlib_oc = (bool) ini_get('zlib.output_compression');
142
+		$this->_compress_output = (
143
+			$this->_zlib_oc === FALSE
144
+			&& config_item('compress_output') === TRUE
145
+			&& extension_loaded('zlib')
146
+		);
147
+
148
+		isset(self::$func_overload) OR self::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
149
+
150
+		// Get mime types for later
151
+		$this->mimes =& get_mimes();
152
+
153
+		log_message('info', 'Output Class Initialized');
154
+	}
155
+
156
+	// --------------------------------------------------------------------
157
+
158
+	/**
159
+	 * Get Output
160
+	 *
161
+	 * Returns the current output string.
162
+	 *
163
+	 * @return	string
164
+	 */
165
+	public function get_output()
166
+	{
167
+		return $this->final_output;
168
+	}
169
+
170
+	// --------------------------------------------------------------------
171
+
172
+	/**
173
+	 * Set Output
174
+	 *
175
+	 * Sets the output string.
176
+	 *
177
+	 * @param	string	$output	Output data
178
+	 * @return	CI_Output
179
+	 */
180
+	public function set_output($output)
181
+	{
182
+		$this->final_output = $output;
183
+		return $this;
184
+	}
185
+
186
+	// --------------------------------------------------------------------
187
+
188
+	/**
189
+	 * Append Output
190
+	 *
191
+	 * Appends data onto the output string.
192
+	 *
193
+	 * @param	string	$output	Data to append
194
+	 * @return	CI_Output
195
+	 */
196
+	public function append_output($output)
197
+	{
198
+		$this->final_output .= $output;
199
+		return $this;
200
+	}
201
+
202
+	// --------------------------------------------------------------------
203
+
204
+	/**
205
+	 * Set Header
206
+	 *
207
+	 * Lets you set a server header which will be sent with the final output.
208
+	 *
209
+	 * Note: If a file is cached, headers will not be sent.
210
+	 * @todo	We need to figure out how to permit headers to be cached.
211
+	 *
212
+	 * @param	string	$header		Header
213
+	 * @param	bool	$replace	Whether to replace the old header value, if already set
214
+	 * @return	CI_Output
215
+	 */
216
+	public function set_header($header, $replace = TRUE)
217
+	{
218
+		// If zlib.output_compression is enabled it will compress the output,
219
+		// but it will not modify the content-length header to compensate for
220
+		// the reduction, causing the browser to hang waiting for more data.
221
+		// We'll just skip content-length in those cases.
222
+		if ($this->_zlib_oc && strncasecmp($header, 'content-length', 14) === 0)
223
+		{
224
+			return $this;
225
+		}
226
+
227
+		$this->headers[] = array($header, $replace);
228
+		return $this;
229
+	}
230
+
231
+	// --------------------------------------------------------------------
232
+
233
+	/**
234
+	 * Set Content-Type Header
235
+	 *
236
+	 * @param	string	$mime_type	Extension of the file we're outputting
237
+	 * @param	string	$charset	Character set (default: NULL)
238
+	 * @return	CI_Output
239
+	 */
240
+	public function set_content_type($mime_type, $charset = NULL)
241
+	{
242
+		if (strpos($mime_type, '/') === FALSE)
243
+		{
244
+			$extension = ltrim($mime_type, '.');
245
+
246
+			// Is this extension supported?
247
+			if (isset($this->mimes[$extension]))
248
+			{
249
+				$mime_type =& $this->mimes[$extension];
250
+
251
+				if (is_array($mime_type))
252
+				{
253
+					$mime_type = current($mime_type);
254
+				}
255
+			}
256
+		}
257
+
258
+		$this->mime_type = $mime_type;
259
+
260
+		if (empty($charset))
261
+		{
262
+			$charset = config_item('charset');
263
+		}
264
+
265
+		$header = 'Content-Type: '.$mime_type
266
+			.(empty($charset) ? '' : '; charset='.$charset);
267
+
268
+		$this->headers[] = array($header, TRUE);
269
+		return $this;
270
+	}
271
+
272
+	// --------------------------------------------------------------------
273
+
274
+	/**
275
+	 * Get Current Content-Type Header
276
+	 *
277
+	 * @return	string	'text/html', if not already set
278
+	 */
279
+	public function get_content_type()
280
+	{
281
+		for ($i = 0, $c = count($this->headers); $i < $c; $i++)
282
+		{
283
+			if (sscanf($this->headers[$i][0], 'Content-Type: %[^;]', $content_type) === 1)
284
+			{
285
+				return $content_type;
286
+			}
287
+		}
288
+
289
+		return 'text/html';
290
+	}
291
+
292
+	// --------------------------------------------------------------------
293
+
294
+	/**
295
+	 * Get Header
296
+	 *
297
+	 * @param	string	$header
298
+	 * @return	string
299
+	 */
300
+	public function get_header($header)
301
+	{
302
+		// Combine headers already sent with our batched headers
303
+		$headers = array_merge(
304
+			// We only need [x][0] from our multi-dimensional array
305
+			array_map('array_shift', $this->headers),
306
+			headers_list()
307
+		);
308
+
309
+		if (empty($headers) OR empty($header))
310
+		{
311
+			return NULL;
312
+		}
313
+
314
+		// Count backwards, in order to get the last matching header
315
+		for ($c = count($headers) - 1; $c > -1; $c--)
316
+		{
317
+			if (strncasecmp($header, $headers[$c], $l = self::strlen($header)) === 0)
318
+			{
319
+				return trim(self::substr($headers[$c], $l+1));
320
+			}
321
+		}
322
+
323
+		return NULL;
324
+	}
325
+
326
+	// --------------------------------------------------------------------
327
+
328
+	/**
329
+	 * Set HTTP Status Header
330
+	 *
331
+	 * As of version 1.7.2, this is an alias for common function
332
+	 * set_status_header().
333
+	 *
334
+	 * @param	int	$code	Status code (default: 200)
335
+	 * @param	string	$text	Optional message
336
+	 * @return	CI_Output
337
+	 */
338
+	public function set_status_header($code = 200, $text = '')
339
+	{
340
+		set_status_header($code, $text);
341
+		return $this;
342
+	}
343
+
344
+	// --------------------------------------------------------------------
345
+
346
+	/**
347
+	 * Enable/disable Profiler
348
+	 *
349
+	 * @param	bool	$val	TRUE to enable or FALSE to disable
350
+	 * @return	CI_Output
351
+	 */
352
+	public function enable_profiler($val = TRUE)
353
+	{
354
+		$this->enable_profiler = is_bool($val) ? $val : TRUE;
355
+		return $this;
356
+	}
357
+
358
+	// --------------------------------------------------------------------
359
+
360
+	/**
361
+	 * Set Profiler Sections
362
+	 *
363
+	 * Allows override of default/config settings for
364
+	 * Profiler section display.
365
+	 *
366
+	 * @param	array	$sections	Profiler sections
367
+	 * @return	CI_Output
368
+	 */
369
+	public function set_profiler_sections($sections)
370
+	{
371
+		if (isset($sections['query_toggle_count']))
372
+		{
373
+			$this->_profiler_sections['query_toggle_count'] = (int) $sections['query_toggle_count'];
374
+			unset($sections['query_toggle_count']);
375
+		}
376
+
377
+		foreach ($sections as $section => $enable)
378
+		{
379
+			$this->_profiler_sections[$section] = ($enable !== FALSE);
380
+		}
381
+
382
+		return $this;
383
+	}
384
+
385
+	// --------------------------------------------------------------------
386
+
387
+	/**
388
+	 * Set Cache
389
+	 *
390
+	 * @param	int	$time	Cache expiration time in minutes
391
+	 * @return	CI_Output
392
+	 */
393
+	public function cache($time)
394
+	{
395
+		$this->cache_expiration = is_numeric($time) ? $time : 0;
396
+		return $this;
397
+	}
398
+
399
+	// --------------------------------------------------------------------
400
+
401
+	/**
402
+	 * Display Output
403
+	 *
404
+	 * Processes and sends finalized output data to the browser along
405
+	 * with any server headers and profile data. It also stops benchmark
406
+	 * timers so the page rendering speed and memory usage can be shown.
407
+	 *
408
+	 * Note: All "view" data is automatically put into $this->final_output
409
+	 *	 by controller class.
410
+	 *
411
+	 * @uses	CI_Output::$final_output
412
+	 * @param	string	$output	Output data override
413
+	 * @return	void
414
+	 */
415
+	public function _display($output = '')
416
+	{
417
+		// Note:  We use load_class() because we can't use $CI =& get_instance()
418
+		// since this function is sometimes called by the caching mechanism,
419
+		// which happens before the CI super object is available.
420
+		$BM =& load_class('Benchmark', 'core');
421
+		$CFG =& load_class('Config', 'core');
422
+
423
+		// Grab the super object if we can.
424
+		if (class_exists('CI_Controller', FALSE))
425
+		{
426
+			$CI =& get_instance();
427
+		}
428
+
429
+		// --------------------------------------------------------------------
430
+
431
+		// Set the output data
432
+		if ($output === '')
433
+		{
434
+			$output =& $this->final_output;
435
+		}
436
+
437
+		// --------------------------------------------------------------------
438
+
439
+		// Do we need to write a cache file? Only if the controller does not have its
440
+		// own _output() method and we are not dealing with a cache file, which we
441
+		// can determine by the existence of the $CI object above
442
+		if ($this->cache_expiration > 0 && isset($CI) && ! method_exists($CI, '_output'))
443
+		{
444
+			$this->_write_cache($output);
445
+		}
446
+
447
+		// --------------------------------------------------------------------
448
+
449
+		// Parse out the elapsed time and memory usage,
450
+		// then swap the pseudo-variables with the data
451
+
452
+		$elapsed = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end');
453
+
454
+		if ($this->parse_exec_vars === TRUE)
455
+		{
456
+			$memory	= round(memory_get_usage() / 1024 / 1024, 2).'MB';
457
+			$output = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output);
458
+		}
459
+
460
+		// --------------------------------------------------------------------
461
+
462
+		// Is compression requested?
463
+		if (isset($CI) // This means that we're not serving a cache file, if we were, it would already be compressed
464
+			&& $this->_compress_output === TRUE
465
+			&& isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
466
+		{
467
+			ob_start('ob_gzhandler');
468
+		}
469
+
470
+		// --------------------------------------------------------------------
471
+
472
+		// Are there any server headers to send?
473
+		if (count($this->headers) > 0)
474
+		{
475
+			foreach ($this->headers as $header)
476
+			{
477
+				@header($header[0], $header[1]);
478
+			}
479
+		}
480
+
481
+		// --------------------------------------------------------------------
482
+
483
+		// Does the $CI object exist?
484
+		// If not we know we are dealing with a cache file so we'll
485
+		// simply echo out the data and exit.
486
+		if ( ! isset($CI))
487
+		{
488
+			if ($this->_compress_output === TRUE)
489
+			{
490
+				if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE)
491
+				{
492
+					header('Content-Encoding: gzip');
493
+					header('Content-Length: '.self::strlen($output));
494
+				}
495
+				else
496
+				{
497
+					// User agent doesn't support gzip compression,
498
+					// so we'll have to decompress our cache
499
+					$output = gzinflate(self::substr($output, 10, -8));
500
+				}
501
+			}
502
+
503
+			echo $output;
504
+			log_message('info', 'Final output sent to browser');
505
+			log_message('debug', 'Total execution time: '.$elapsed);
506
+			return;
507
+		}
508
+
509
+		// --------------------------------------------------------------------
510
+
511
+		// Do we need to generate profile data?
512
+		// If so, load the Profile class and run it.
513
+		if ($this->enable_profiler === TRUE)
514
+		{
515
+			$CI->load->library('profiler');
516
+			if ( ! empty($this->_profiler_sections))
517
+			{
518
+				$CI->profiler->set_sections($this->_profiler_sections);
519
+			}
520
+
521
+			// If the output data contains closing </body> and </html> tags
522
+			// we will remove them and add them back after we insert the profile data
523
+			$output = preg_replace('|</body>.*?</html>|is', '', $output, -1, $count).$CI->profiler->run();
524
+			if ($count > 0)
525
+			{
526
+				$output .= '</body></html>';
527
+			}
528
+		}
529
+
530
+		// Does the controller contain a function named _output()?
531
+		// If so send the output there.  Otherwise, echo it.
532
+		if (method_exists($CI, '_output'))
533
+		{
534
+			$CI->_output($output);
535
+		}
536
+		else
537
+		{
538
+			echo $output; // Send it to the browser!
539
+		}
540
+
541
+		log_message('info', 'Final output sent to browser');
542
+		log_message('debug', 'Total execution time: '.$elapsed);
543
+	}
544
+
545
+	// --------------------------------------------------------------------
546
+
547
+	/**
548
+	 * Write Cache
549
+	 *
550
+	 * @param	string	$output	Output data to cache
551
+	 * @return	void
552
+	 */
553
+	public function _write_cache($output)
554
+	{
555
+		$CI =& get_instance();
556
+		$path = $CI->config->item('cache_path');
557
+		$cache_path = ($path === '') ? APPPATH.'cache/' : $path;
558
+
559
+		if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path))
560
+		{
561
+			log_message('error', 'Unable to write cache file: '.$cache_path);
562
+			return;
563
+		}
564
+
565
+		$uri = $CI->config->item('base_url')
566
+			.$CI->config->item('index_page')
567
+			.$CI->uri->uri_string();
568
+
569
+		if (($cache_query_string = $CI->config->item('cache_query_string')) && ! empty($_SERVER['QUERY_STRING']))
570
+		{
571
+			if (is_array($cache_query_string))
572
+			{
573
+				$uri .= '?'.http_build_query(array_intersect_key($_GET, array_flip($cache_query_string)));
574
+			}
575
+			else
576
+			{
577
+				$uri .= '?'.$_SERVER['QUERY_STRING'];
578
+			}
579
+		}
580
+
581
+		$cache_path .= md5($uri);
582
+
583
+		if ( ! $fp = @fopen($cache_path, 'w+b'))
584
+		{
585
+			log_message('error', 'Unable to write cache file: '.$cache_path);
586
+			return;
587
+		}
588
+
589
+		if ( ! flock($fp, LOCK_EX))
590
+		{
591
+			log_message('error', 'Unable to secure a file lock for file at: '.$cache_path);
592
+			fclose($fp);
593
+			return;
594
+		}
595
+
596
+		// If output compression is enabled, compress the cache
597
+		// itself, so that we don't have to do that each time
598
+		// we're serving it
599
+		if ($this->_compress_output === TRUE)
600
+		{
601
+			$output = gzencode($output);
602
+
603
+			if ($this->get_header('content-type') === NULL)
604
+			{
605
+				$this->set_content_type($this->mime_type);
606
+			}
607
+		}
608
+
609
+		$expire = time() + ($this->cache_expiration * 60);
610
+
611
+		// Put together our serialized info.
612
+		$cache_info = serialize(array(
613
+			'expire'	=> $expire,
614
+			'headers'	=> $this->headers
615
+		));
616
+
617
+		$output = $cache_info.'ENDCI--->'.$output;
618
+
619
+		for ($written = 0, $length = self::strlen($output); $written < $length; $written += $result)
620
+		{
621
+			if (($result = fwrite($fp, self::substr($output, $written))) === FALSE)
622
+			{
623
+				break;
624
+			}
625
+		}
626
+
627
+		flock($fp, LOCK_UN);
628
+		fclose($fp);
629
+
630
+		if ( ! is_int($result))
631
+		{
632
+			@unlink($cache_path);
633
+			log_message('error', 'Unable to write the complete cache content at: '.$cache_path);
634
+			return;
635
+		}
636
+
637
+		chmod($cache_path, 0640);
638
+		log_message('debug', 'Cache file written: '.$cache_path);
639
+
640
+		// Send HTTP cache-control headers to browser to match file cache settings.
641
+		$this->set_cache_header($_SERVER['REQUEST_TIME'], $expire);
642
+	}
643
+
644
+	// --------------------------------------------------------------------
645
+
646
+	/**
647
+	 * Update/serve cached output
648
+	 *
649
+	 * @uses	CI_Config
650
+	 * @uses	CI_URI
651
+	 *
652
+	 * @param	object	&$CFG	CI_Config class instance
653
+	 * @param	object	&$URI	CI_URI class instance
654
+	 * @return	bool	TRUE on success or FALSE on failure
655
+	 */
656
+	public function _display_cache(&$CFG, &$URI)
657
+	{
658
+		$cache_path = ($CFG->item('cache_path') === '') ? APPPATH.'cache/' : $CFG->item('cache_path');
659
+
660
+		// Build the file path. The file name is an MD5 hash of the full URI
661
+		$uri = $CFG->item('base_url').$CFG->item('index_page').$URI->uri_string;
662
+
663
+		if (($cache_query_string = $CFG->item('cache_query_string')) && ! empty($_SERVER['QUERY_STRING']))
664
+		{
665
+			if (is_array($cache_query_string))
666
+			{
667
+				$uri .= '?'.http_build_query(array_intersect_key($_GET, array_flip($cache_query_string)));
668
+			}
669
+			else
670
+			{
671
+				$uri .= '?'.$_SERVER['QUERY_STRING'];
672
+			}
673
+		}
674
+
675
+		$filepath = $cache_path.md5($uri);
676
+
677
+		if ( ! file_exists($filepath) OR ! $fp = @fopen($filepath, 'rb'))
678
+		{
679
+			return FALSE;
680
+		}
681
+
682
+		flock($fp, LOCK_SH);
683
+
684
+		$cache = (filesize($filepath) > 0) ? fread($fp, filesize($filepath)) : '';
685
+
686
+		flock($fp, LOCK_UN);
687
+		fclose($fp);
688
+
689
+		// Look for embedded serialized file info.
690
+		if ( ! preg_match('/^(.*)ENDCI--->/', $cache, $match))
691
+		{
692
+			return FALSE;
693
+		}
694
+
695
+		$cache_info = unserialize($match[1]);
696
+		$expire = $cache_info['expire'];
697
+
698
+		$last_modified = filemtime($filepath);
699
+
700
+		// Has the file expired?
701
+		if ($_SERVER['REQUEST_TIME'] >= $expire && is_really_writable($cache_path))
702
+		{
703
+			// If so we'll delete it.
704
+			@unlink($filepath);
705
+			log_message('debug', 'Cache file has expired. File deleted.');
706
+			return FALSE;
707
+		}
708
+
709
+		// Send the HTTP cache control headers
710
+		$this->set_cache_header($last_modified, $expire);
711
+
712
+		// Add headers from cache file.
713
+		foreach ($cache_info['headers'] as $header)
714
+		{
715
+			$this->set_header($header[0], $header[1]);
716
+		}
717
+
718
+		// Display the cache
719
+		$this->_display(self::substr($cache, self::strlen($match[0])));
720
+		log_message('debug', 'Cache file is current. Sending it to browser.');
721
+		return TRUE;
722
+	}
723
+
724
+	// --------------------------------------------------------------------
725
+
726
+	/**
727
+	 * Delete cache
728
+	 *
729
+	 * @param	string	$uri	URI string
730
+	 * @return	bool
731
+	 */
732
+	public function delete_cache($uri = '')
733
+	{
734
+		$CI =& get_instance();
735
+		$cache_path = $CI->config->item('cache_path');
736
+		if ($cache_path === '')
737
+		{
738
+			$cache_path = APPPATH.'cache/';
739
+		}
740
+
741
+		if ( ! is_dir($cache_path))
742
+		{
743
+			log_message('error', 'Unable to find cache path: '.$cache_path);
744
+			return FALSE;
745
+		}
746
+
747
+		if (empty($uri))
748
+		{
749
+			$uri = $CI->uri->uri_string();
750
+
751
+			if (($cache_query_string = $CI->config->item('cache_query_string')) && ! empty($_SERVER['QUERY_STRING']))
752
+			{
753
+				if (is_array($cache_query_string))
754
+				{
755
+					$uri .= '?'.http_build_query(array_intersect_key($_GET, array_flip($cache_query_string)));
756
+				}
757
+				else
758
+				{
759
+					$uri .= '?'.$_SERVER['QUERY_STRING'];
760
+				}
761
+			}
762
+		}
763
+
764
+		$cache_path .= md5($CI->config->item('base_url').$CI->config->item('index_page').ltrim($uri, '/'));
765
+
766
+		if ( ! @unlink($cache_path))
767
+		{
768
+			log_message('error', 'Unable to delete cache file for '.$uri);
769
+			return FALSE;
770
+		}
771
+
772
+		return TRUE;
773
+	}
774
+
775
+	// --------------------------------------------------------------------
776
+
777
+	/**
778
+	 * Set Cache Header
779
+	 *
780
+	 * Set the HTTP headers to match the server-side file cache settings
781
+	 * in order to reduce bandwidth.
782
+	 *
783
+	 * @param	int	$last_modified	Timestamp of when the page was last modified
784
+	 * @param	int	$expiration	Timestamp of when should the requested page expire from cache
785
+	 * @return	void
786
+	 */
787
+	public function set_cache_header($last_modified, $expiration)
788
+	{
789
+		$max_age = $expiration - $_SERVER['REQUEST_TIME'];
790
+
791
+		if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $last_modified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']))
792
+		{
793
+			$this->set_status_header(304);
794
+			exit;
795
+		}
796
+
797
+		header('Pragma: public');
798
+		header('Cache-Control: max-age='.$max_age.', public');
799
+		header('Expires: '.gmdate('D, d M Y H:i:s', $expiration).' GMT');
800
+		header('Last-modified: '.gmdate('D, d M Y H:i:s', $last_modified).' GMT');
801
+	}
802
+
803
+	// --------------------------------------------------------------------
804
+
805
+	/**
806
+	 * Byte-safe strlen()
807
+	 *
808
+	 * @param	string	$str
809
+	 * @return	int
810
+	 */
811
+	protected static function strlen($str)
812
+	{
813
+		return (self::$func_overload)
814
+			? mb_strlen($str, '8bit')
815
+			: strlen($str);
816
+	}
817
+
818
+	// --------------------------------------------------------------------
819
+
820
+	/**
821
+	 * Byte-safe substr()
822
+	 *
823
+	 * @param	string	$str
824
+	 * @param	int	$start
825
+	 * @param	int	$length
826
+	 * @return	string
827
+	 */
828
+	protected static function substr($str, $start, $length = NULL)
829
+	{
830
+		if (self::$func_overload)
831
+		{
832
+			// mb_substr($str, $start, null, '8bit') returns an empty
833
+			// string on PHP 5.3
834
+			isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
835
+			return mb_substr($str, $start, $length, '8bit');
836
+		}
837
+
838
+		return isset($length)
839
+			? substr($str, $start, $length)
840
+			: substr($str, $start);
841
+	}
842
+}

+ 515 - 0
system/core/Router.php Datei anzeigen

@@ -0,0 +1,515 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Router Class
42
+ *
43
+ * Parses URIs and determines routing
44
+ *
45
+ * @package		CodeIgniter
46
+ * @subpackage	Libraries
47
+ * @category	Libraries
48
+ * @author		EllisLab Dev Team
49
+ * @link		https://codeigniter.com/user_guide/general/routing.html
50
+ */
51
+class CI_Router {
52
+
53
+	/**
54
+	 * CI_Config class object
55
+	 *
56
+	 * @var	object
57
+	 */
58
+	public $config;
59
+
60
+	/**
61
+	 * List of routes
62
+	 *
63
+	 * @var	array
64
+	 */
65
+	public $routes =	array();
66
+
67
+	/**
68
+	 * Current class name
69
+	 *
70
+	 * @var	string
71
+	 */
72
+	public $class =		'';
73
+
74
+	/**
75
+	 * Current method name
76
+	 *
77
+	 * @var	string
78
+	 */
79
+	public $method =	'index';
80
+
81
+	/**
82
+	 * Sub-directory that contains the requested controller class
83
+	 *
84
+	 * @var	string
85
+	 */
86
+	public $directory;
87
+
88
+	/**
89
+	 * Default controller (and method if specific)
90
+	 *
91
+	 * @var	string
92
+	 */
93
+	public $default_controller;
94
+
95
+	/**
96
+	 * Translate URI dashes
97
+	 *
98
+	 * Determines whether dashes in controller & method segments
99
+	 * should be automatically replaced by underscores.
100
+	 *
101
+	 * @var	bool
102
+	 */
103
+	public $translate_uri_dashes = FALSE;
104
+
105
+	/**
106
+	 * Enable query strings flag
107
+	 *
108
+	 * Determines whether to use GET parameters or segment URIs
109
+	 *
110
+	 * @var	bool
111
+	 */
112
+	public $enable_query_strings = FALSE;
113
+
114
+	// --------------------------------------------------------------------
115
+
116
+	/**
117
+	 * Class constructor
118
+	 *
119
+	 * Runs the route mapping function.
120
+	 *
121
+	 * @param	array	$routing
122
+	 * @return	void
123
+	 */
124
+	public function __construct($routing = NULL)
125
+	{
126
+		$this->config =& load_class('Config', 'core');
127
+		$this->uri =& load_class('URI', 'core');
128
+
129
+		$this->enable_query_strings = ( ! is_cli() && $this->config->item('enable_query_strings') === TRUE);
130
+
131
+		// If a directory override is configured, it has to be set before any dynamic routing logic
132
+		is_array($routing) && isset($routing['directory']) && $this->set_directory($routing['directory']);
133
+		$this->_set_routing();
134
+
135
+		// Set any routing overrides that may exist in the main index file
136
+		if (is_array($routing))
137
+		{
138
+			empty($routing['controller']) OR $this->set_class($routing['controller']);
139
+			empty($routing['function'])   OR $this->set_method($routing['function']);
140
+		}
141
+
142
+		log_message('info', 'Router Class Initialized');
143
+	}
144
+
145
+	// --------------------------------------------------------------------
146
+
147
+	/**
148
+	 * Set route mapping
149
+	 *
150
+	 * Determines what should be served based on the URI request,
151
+	 * as well as any "routes" that have been set in the routing config file.
152
+	 *
153
+	 * @return	void
154
+	 */
155
+	protected function _set_routing()
156
+	{
157
+		// Load the routes.php file. It would be great if we could
158
+		// skip this for enable_query_strings = TRUE, but then
159
+		// default_controller would be empty ...
160
+		if (file_exists(APPPATH.'config/routes.php'))
161
+		{
162
+			include(APPPATH.'config/routes.php');
163
+		}
164
+
165
+		if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
166
+		{
167
+			include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
168
+		}
169
+
170
+		// Validate & get reserved routes
171
+		if (isset($route) && is_array($route))
172
+		{
173
+			isset($route['default_controller']) && $this->default_controller = $route['default_controller'];
174
+			isset($route['translate_uri_dashes']) && $this->translate_uri_dashes = $route['translate_uri_dashes'];
175
+			unset($route['default_controller'], $route['translate_uri_dashes']);
176
+			$this->routes = $route;
177
+		}
178
+
179
+		// Are query strings enabled in the config file? Normally CI doesn't utilize query strings
180
+		// since URI segments are more search-engine friendly, but they can optionally be used.
181
+		// If this feature is enabled, we will gather the directory/class/method a little differently
182
+		if ($this->enable_query_strings)
183
+		{
184
+			// If the directory is set at this time, it means an override exists, so skip the checks
185
+			if ( ! isset($this->directory))
186
+			{
187
+				$_d = $this->config->item('directory_trigger');
188
+				$_d = isset($_GET[$_d]) ? trim($_GET[$_d], " \t\n\r\0\x0B/") : '';
189
+
190
+				if ($_d !== '')
191
+				{
192
+					$this->uri->filter_uri($_d);
193
+					$this->set_directory($_d);
194
+				}
195
+			}
196
+
197
+			$_c = trim($this->config->item('controller_trigger'));
198
+			if ( ! empty($_GET[$_c]))
199
+			{
200
+				$this->uri->filter_uri($_GET[$_c]);
201
+				$this->set_class($_GET[$_c]);
202
+
203
+				$_f = trim($this->config->item('function_trigger'));
204
+				if ( ! empty($_GET[$_f]))
205
+				{
206
+					$this->uri->filter_uri($_GET[$_f]);
207
+					$this->set_method($_GET[$_f]);
208
+				}
209
+
210
+				$this->uri->rsegments = array(
211
+					1 => $this->class,
212
+					2 => $this->method
213
+				);
214
+			}
215
+			else
216
+			{
217
+				$this->_set_default_controller();
218
+			}
219
+
220
+			// Routing rules don't apply to query strings and we don't need to detect
221
+			// directories, so we're done here
222
+			return;
223
+		}
224
+
225
+		// Is there anything to parse?
226
+		if ($this->uri->uri_string !== '')
227
+		{
228
+			$this->_parse_routes();
229
+		}
230
+		else
231
+		{
232
+			$this->_set_default_controller();
233
+		}
234
+	}
235
+
236
+	// --------------------------------------------------------------------
237
+
238
+	/**
239
+	 * Set request route
240
+	 *
241
+	 * Takes an array of URI segments as input and sets the class/method
242
+	 * to be called.
243
+	 *
244
+	 * @used-by	CI_Router::_parse_routes()
245
+	 * @param	array	$segments	URI segments
246
+	 * @return	void
247
+	 */
248
+	protected function _set_request($segments = array())
249
+	{
250
+		$segments = $this->_validate_request($segments);
251
+		// If we don't have any segments left - try the default controller;
252
+		// WARNING: Directories get shifted out of the segments array!
253
+		if (empty($segments))
254
+		{
255
+			$this->_set_default_controller();
256
+			return;
257
+		}
258
+
259
+		if ($this->translate_uri_dashes === TRUE)
260
+		{
261
+			$segments[0] = str_replace('-', '_', $segments[0]);
262
+			if (isset($segments[1]))
263
+			{
264
+				$segments[1] = str_replace('-', '_', $segments[1]);
265
+			}
266
+		}
267
+
268
+		$this->set_class($segments[0]);
269
+		if (isset($segments[1]))
270
+		{
271
+			$this->set_method($segments[1]);
272
+		}
273
+		else
274
+		{
275
+			$segments[1] = 'index';
276
+		}
277
+
278
+		array_unshift($segments, NULL);
279
+		unset($segments[0]);
280
+		$this->uri->rsegments = $segments;
281
+	}
282
+
283
+	// --------------------------------------------------------------------
284
+
285
+	/**
286
+	 * Set default controller
287
+	 *
288
+	 * @return	void
289
+	 */
290
+	protected function _set_default_controller()
291
+	{
292
+		if (empty($this->default_controller))
293
+		{
294
+			show_error('Unable to determine what should be displayed. A default route has not been specified in the routing file.');
295
+		}
296
+
297
+		// Is the method being specified?
298
+		if (sscanf($this->default_controller, '%[^/]/%s', $class, $method) !== 2)
299
+		{
300
+			$method = 'index';
301
+		}
302
+
303
+		if ( ! file_exists(APPPATH.'controllers/'.$this->directory.ucfirst($class).'.php'))
304
+		{
305
+			// This will trigger 404 later
306
+			return;
307
+		}
308
+
309
+		$this->set_class($class);
310
+		$this->set_method($method);
311
+
312
+		// Assign routed segments, index starting from 1
313
+		$this->uri->rsegments = array(
314
+			1 => $class,
315
+			2 => $method
316
+		);
317
+
318
+		log_message('debug', 'No URI present. Default controller set.');
319
+	}
320
+
321
+	// --------------------------------------------------------------------
322
+
323
+	/**
324
+	 * Validate request
325
+	 *
326
+	 * Attempts validate the URI request and determine the controller path.
327
+	 *
328
+	 * @used-by	CI_Router::_set_request()
329
+	 * @param	array	$segments	URI segments
330
+	 * @return	mixed	URI segments
331
+	 */
332
+	protected function _validate_request($segments)
333
+	{
334
+		$c = count($segments);
335
+		$directory_override = isset($this->directory);
336
+
337
+		// Loop through our segments and return as soon as a controller
338
+		// is found or when such a directory doesn't exist
339
+		while ($c-- > 0)
340
+		{
341
+			$test = $this->directory
342
+				.ucfirst($this->translate_uri_dashes === TRUE ? str_replace('-', '_', $segments[0]) : $segments[0]);
343
+
344
+			if ( ! file_exists(APPPATH.'controllers/'.$test.'.php')
345
+				&& $directory_override === FALSE
346
+				&& is_dir(APPPATH.'controllers/'.$this->directory.$segments[0])
347
+			)
348
+			{
349
+				$this->set_directory(array_shift($segments), TRUE);
350
+				continue;
351
+			}
352
+
353
+			return $segments;
354
+		}
355
+
356
+		// This means that all segments were actually directories
357
+		return $segments;
358
+	}
359
+
360
+	// --------------------------------------------------------------------
361
+
362
+	/**
363
+	 * Parse Routes
364
+	 *
365
+	 * Matches any routes that may exist in the config/routes.php file
366
+	 * against the URI to determine if the class/method need to be remapped.
367
+	 *
368
+	 * @return	void
369
+	 */
370
+	protected function _parse_routes()
371
+	{
372
+		// Turn the segment array into a URI string
373
+		$uri = implode('/', $this->uri->segments);
374
+
375
+		// Get HTTP verb
376
+		$http_verb = isset($_SERVER['REQUEST_METHOD']) ? strtolower($_SERVER['REQUEST_METHOD']) : 'cli';
377
+
378
+		// Loop through the route array looking for wildcards
379
+		foreach ($this->routes as $key => $val)
380
+		{
381
+			// Check if route format is using HTTP verbs
382
+			if (is_array($val))
383
+			{
384
+				$val = array_change_key_case($val, CASE_LOWER);
385
+				if (isset($val[$http_verb]))
386
+				{
387
+					$val = $val[$http_verb];
388
+				}
389
+				else
390
+				{
391
+					continue;
392
+				}
393
+			}
394
+
395
+			// Convert wildcards to RegEx
396
+			$key = str_replace(array(':any', ':num'), array('[^/]+', '[0-9]+'), $key);
397
+
398
+			// Does the RegEx match?
399
+			if (preg_match('#^'.$key.'$#', $uri, $matches))
400
+			{
401
+				// Are we using callbacks to process back-references?
402
+				if ( ! is_string($val) && is_callable($val))
403
+				{
404
+					// Remove the original string from the matches array.
405
+					array_shift($matches);
406
+
407
+					// Execute the callback using the values in matches as its parameters.
408
+					$val = call_user_func_array($val, $matches);
409
+				}
410
+				// Are we using the default routing method for back-references?
411
+				elseif (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE)
412
+				{
413
+					$val = preg_replace('#^'.$key.'$#', $val, $uri);
414
+				}
415
+
416
+				$this->_set_request(explode('/', $val));
417
+				return;
418
+			}
419
+		}
420
+
421
+		// If we got this far it means we didn't encounter a
422
+		// matching route so we'll set the site default route
423
+		$this->_set_request(array_values($this->uri->segments));
424
+	}
425
+
426
+	// --------------------------------------------------------------------
427
+
428
+	/**
429
+	 * Set class name
430
+	 *
431
+	 * @param	string	$class	Class name
432
+	 * @return	void
433
+	 */
434
+	public function set_class($class)
435
+	{
436
+		$this->class = str_replace(array('/', '.'), '', $class);
437
+	}
438
+
439
+	// --------------------------------------------------------------------
440
+
441
+	/**
442
+	 * Fetch the current class
443
+	 *
444
+	 * @deprecated	3.0.0	Read the 'class' property instead
445
+	 * @return	string
446
+	 */
447
+	public function fetch_class()
448
+	{
449
+		return $this->class;
450
+	}
451
+
452
+	// --------------------------------------------------------------------
453
+
454
+	/**
455
+	 * Set method name
456
+	 *
457
+	 * @param	string	$method	Method name
458
+	 * @return	void
459
+	 */
460
+	public function set_method($method)
461
+	{
462
+		$this->method = $method;
463
+	}
464
+
465
+	// --------------------------------------------------------------------
466
+
467
+	/**
468
+	 * Fetch the current method
469
+	 *
470
+	 * @deprecated	3.0.0	Read the 'method' property instead
471
+	 * @return	string
472
+	 */
473
+	public function fetch_method()
474
+	{
475
+		return $this->method;
476
+	}
477
+
478
+	// --------------------------------------------------------------------
479
+
480
+	/**
481
+	 * Set directory name
482
+	 *
483
+	 * @param	string	$dir	Directory name
484
+	 * @param	bool	$append	Whether we're appending rather than setting the full value
485
+	 * @return	void
486
+	 */
487
+	public function set_directory($dir, $append = FALSE)
488
+	{
489
+		if ($append !== TRUE OR empty($this->directory))
490
+		{
491
+			$this->directory = str_replace('.', '', trim($dir, '/')).'/';
492
+		}
493
+		else
494
+		{
495
+			$this->directory .= str_replace('.', '', trim($dir, '/')).'/';
496
+		}
497
+	}
498
+
499
+	// --------------------------------------------------------------------
500
+
501
+	/**
502
+	 * Fetch directory
503
+	 *
504
+	 * Feches the sub-directory (if any) that contains the requested
505
+	 * controller class.
506
+	 *
507
+	 * @deprecated	3.0.0	Read the 'directory' property instead
508
+	 * @return	string
509
+	 */
510
+	public function fetch_directory()
511
+	{
512
+		return $this->directory;
513
+	}
514
+
515
+}

Datei-Diff unterdrückt, da er zu groß ist
+ 1091 - 0
system/core/Security.php


+ 643 - 0
system/core/URI.php Datei anzeigen

@@ -0,0 +1,643 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * URI Class
42
+ *
43
+ * Parses URIs and determines routing
44
+ *
45
+ * @package		CodeIgniter
46
+ * @subpackage	Libraries
47
+ * @category	URI
48
+ * @author		EllisLab Dev Team
49
+ * @link		https://codeigniter.com/user_guide/libraries/uri.html
50
+ */
51
+class CI_URI {
52
+
53
+	/**
54
+	 * List of cached URI segments
55
+	 *
56
+	 * @var	array
57
+	 */
58
+	public $keyval = array();
59
+
60
+	/**
61
+	 * Current URI string
62
+	 *
63
+	 * @var	string
64
+	 */
65
+	public $uri_string = '';
66
+
67
+	/**
68
+	 * List of URI segments
69
+	 *
70
+	 * Starts at 1 instead of 0.
71
+	 *
72
+	 * @var	array
73
+	 */
74
+	public $segments = array();
75
+
76
+	/**
77
+	 * List of routed URI segments
78
+	 *
79
+	 * Starts at 1 instead of 0.
80
+	 *
81
+	 * @var	array
82
+	 */
83
+	public $rsegments = array();
84
+
85
+	/**
86
+	 * Permitted URI chars
87
+	 *
88
+	 * PCRE character group allowed in URI segments
89
+	 *
90
+	 * @var	string
91
+	 */
92
+	protected $_permitted_uri_chars;
93
+
94
+	/**
95
+	 * Class constructor
96
+	 *
97
+	 * @return	void
98
+	 */
99
+	public function __construct()
100
+	{
101
+		$this->config =& load_class('Config', 'core');
102
+
103
+		// If query strings are enabled, we don't need to parse any segments.
104
+		// However, they don't make sense under CLI.
105
+		if (is_cli() OR $this->config->item('enable_query_strings') !== TRUE)
106
+		{
107
+			$this->_permitted_uri_chars = $this->config->item('permitted_uri_chars');
108
+
109
+			// If it's a CLI request, ignore the configuration
110
+			if (is_cli())
111
+			{
112
+				$uri = $this->_parse_argv();
113
+			}
114
+			else
115
+			{
116
+				$protocol = $this->config->item('uri_protocol');
117
+				empty($protocol) && $protocol = 'REQUEST_URI';
118
+
119
+				switch ($protocol)
120
+				{
121
+					case 'AUTO': // For BC purposes only
122
+					case 'REQUEST_URI':
123
+						$uri = $this->_parse_request_uri();
124
+						break;
125
+					case 'QUERY_STRING':
126
+						$uri = $this->_parse_query_string();
127
+						break;
128
+					case 'PATH_INFO':
129
+					default:
130
+						$uri = isset($_SERVER[$protocol])
131
+							? $_SERVER[$protocol]
132
+							: $this->_parse_request_uri();
133
+						break;
134
+				}
135
+			}
136
+
137
+			$this->_set_uri_string($uri);
138
+		}
139
+
140
+		log_message('info', 'URI Class Initialized');
141
+	}
142
+
143
+	// --------------------------------------------------------------------
144
+
145
+	/**
146
+	 * Set URI String
147
+	 *
148
+	 * @param 	string	$str
149
+	 * @return	void
150
+	 */
151
+	protected function _set_uri_string($str)
152
+	{
153
+		// Filter out control characters and trim slashes
154
+		$this->uri_string = trim(remove_invisible_characters($str, FALSE), '/');
155
+
156
+		if ($this->uri_string !== '')
157
+		{
158
+			// Remove the URL suffix, if present
159
+			if (($suffix = (string) $this->config->item('url_suffix')) !== '')
160
+			{
161
+				$slen = strlen($suffix);
162
+
163
+				if (substr($this->uri_string, -$slen) === $suffix)
164
+				{
165
+					$this->uri_string = substr($this->uri_string, 0, -$slen);
166
+				}
167
+			}
168
+
169
+			$this->segments[0] = NULL;
170
+			// Populate the segments array
171
+			foreach (explode('/', trim($this->uri_string, '/')) as $val)
172
+			{
173
+				$val = trim($val);
174
+				// Filter segments for security
175
+				$this->filter_uri($val);
176
+
177
+				if ($val !== '')
178
+				{
179
+					$this->segments[] = $val;
180
+				}
181
+			}
182
+
183
+			unset($this->segments[0]);
184
+		}
185
+	}
186
+
187
+	// --------------------------------------------------------------------
188
+
189
+	/**
190
+	 * Parse REQUEST_URI
191
+	 *
192
+	 * Will parse REQUEST_URI and automatically detect the URI from it,
193
+	 * while fixing the query string if necessary.
194
+	 *
195
+	 * @return	string
196
+	 */
197
+	protected function _parse_request_uri()
198
+	{
199
+		if ( ! isset($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME']))
200
+		{
201
+			return '';
202
+		}
203
+
204
+		// parse_url() returns false if no host is present, but the path or query string
205
+		// contains a colon followed by a number
206
+		$uri = parse_url('http://dummy'.$_SERVER['REQUEST_URI']);
207
+		$query = isset($uri['query']) ? $uri['query'] : '';
208
+		$uri = isset($uri['path']) ? $uri['path'] : '';
209
+
210
+		if (isset($_SERVER['SCRIPT_NAME'][0]))
211
+		{
212
+			if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
213
+			{
214
+				$uri = (string) substr($uri, strlen($_SERVER['SCRIPT_NAME']));
215
+			}
216
+			elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
217
+			{
218
+				$uri = (string) substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
219
+			}
220
+		}
221
+
222
+		// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
223
+		// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
224
+		if (trim($uri, '/') === '' && strncmp($query, '/', 1) === 0)
225
+		{
226
+			$query = explode('?', $query, 2);
227
+			$uri = $query[0];
228
+			$_SERVER['QUERY_STRING'] = isset($query[1]) ? $query[1] : '';
229
+		}
230
+		else
231
+		{
232
+			$_SERVER['QUERY_STRING'] = $query;
233
+		}
234
+
235
+		parse_str($_SERVER['QUERY_STRING'], $_GET);
236
+
237
+		if ($uri === '/' OR $uri === '')
238
+		{
239
+			return '/';
240
+		}
241
+
242
+		// Do some final cleaning of the URI and return it
243
+		return $this->_remove_relative_directory($uri);
244
+	}
245
+
246
+	// --------------------------------------------------------------------
247
+
248
+	/**
249
+	 * Parse QUERY_STRING
250
+	 *
251
+	 * Will parse QUERY_STRING and automatically detect the URI from it.
252
+	 *
253
+	 * @return	string
254
+	 */
255
+	protected function _parse_query_string()
256
+	{
257
+		$uri = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
258
+
259
+		if (trim($uri, '/') === '')
260
+		{
261
+			return '';
262
+		}
263
+		elseif (strncmp($uri, '/', 1) === 0)
264
+		{
265
+			$uri = explode('?', $uri, 2);
266
+			$_SERVER['QUERY_STRING'] = isset($uri[1]) ? $uri[1] : '';
267
+			$uri = $uri[0];
268
+		}
269
+
270
+		parse_str($_SERVER['QUERY_STRING'], $_GET);
271
+
272
+		return $this->_remove_relative_directory($uri);
273
+	}
274
+
275
+	// --------------------------------------------------------------------
276
+
277
+	/**
278
+	 * Parse CLI arguments
279
+	 *
280
+	 * Take each command line argument and assume it is a URI segment.
281
+	 *
282
+	 * @return	string
283
+	 */
284
+	protected function _parse_argv()
285
+	{
286
+		$args = array_slice($_SERVER['argv'], 1);
287
+		return $args ? implode('/', $args) : '';
288
+	}
289
+
290
+	// --------------------------------------------------------------------
291
+
292
+	/**
293
+	 * Remove relative directory (../) and multi slashes (///)
294
+	 *
295
+	 * Do some final cleaning of the URI and return it, currently only used in self::_parse_request_uri()
296
+	 *
297
+	 * @param	string	$uri
298
+	 * @return	string
299
+	 */
300
+	protected function _remove_relative_directory($uri)
301
+	{
302
+		$uris = array();
303
+		$tok = strtok($uri, '/');
304
+		while ($tok !== FALSE)
305
+		{
306
+			if (( ! empty($tok) OR $tok === '0') && $tok !== '..')
307
+			{
308
+				$uris[] = $tok;
309
+			}
310
+			$tok = strtok('/');
311
+		}
312
+
313
+		return implode('/', $uris);
314
+	}
315
+
316
+	// --------------------------------------------------------------------
317
+
318
+	/**
319
+	 * Filter URI
320
+	 *
321
+	 * Filters segments for malicious characters.
322
+	 *
323
+	 * @param	string	$str
324
+	 * @return	void
325
+	 */
326
+	public function filter_uri(&$str)
327
+	{
328
+		if ( ! empty($str) && ! empty($this->_permitted_uri_chars) && ! preg_match('/^['.$this->_permitted_uri_chars.']+$/i'.(UTF8_ENABLED ? 'u' : ''), $str))
329
+		{
330
+			show_error('The URI you submitted has disallowed characters.', 400);
331
+		}
332
+	}
333
+
334
+	// --------------------------------------------------------------------
335
+
336
+	/**
337
+	 * Fetch URI Segment
338
+	 *
339
+	 * @see		CI_URI::$segments
340
+	 * @param	int		$n		Index
341
+	 * @param	mixed		$no_result	What to return if the segment index is not found
342
+	 * @return	mixed
343
+	 */
344
+	public function segment($n, $no_result = NULL)
345
+	{
346
+		return isset($this->segments[$n]) ? $this->segments[$n] : $no_result;
347
+	}
348
+
349
+	// --------------------------------------------------------------------
350
+
351
+	/**
352
+	 * Fetch URI "routed" Segment
353
+	 *
354
+	 * Returns the re-routed URI segment (assuming routing rules are used)
355
+	 * based on the index provided. If there is no routing, will return
356
+	 * the same result as CI_URI::segment().
357
+	 *
358
+	 * @see		CI_URI::$rsegments
359
+	 * @see		CI_URI::segment()
360
+	 * @param	int		$n		Index
361
+	 * @param	mixed		$no_result	What to return if the segment index is not found
362
+	 * @return	mixed
363
+	 */
364
+	public function rsegment($n, $no_result = NULL)
365
+	{
366
+		return isset($this->rsegments[$n]) ? $this->rsegments[$n] : $no_result;
367
+	}
368
+
369
+	// --------------------------------------------------------------------
370
+
371
+	/**
372
+	 * URI to assoc
373
+	 *
374
+	 * Generates an associative array of URI data starting at the supplied
375
+	 * segment index. For example, if this is your URI:
376
+	 *
377
+	 *	example.com/user/search/name/joe/location/UK/gender/male
378
+	 *
379
+	 * You can use this method to generate an array with this prototype:
380
+	 *
381
+	 *	array (
382
+	 *		name => joe
383
+	 *		location => UK
384
+	 *		gender => male
385
+	 *	 )
386
+	 *
387
+	 * @param	int	$n		Index (default: 3)
388
+	 * @param	array	$default	Default values
389
+	 * @return	array
390
+	 */
391
+	public function uri_to_assoc($n = 3, $default = array())
392
+	{
393
+		return $this->_uri_to_assoc($n, $default, 'segment');
394
+	}
395
+
396
+	// --------------------------------------------------------------------
397
+
398
+	/**
399
+	 * Routed URI to assoc
400
+	 *
401
+	 * Identical to CI_URI::uri_to_assoc(), only it uses the re-routed
402
+	 * segment array.
403
+	 *
404
+	 * @see		CI_URI::uri_to_assoc()
405
+	 * @param 	int	$n		Index (default: 3)
406
+	 * @param 	array	$default	Default values
407
+	 * @return 	array
408
+	 */
409
+	public function ruri_to_assoc($n = 3, $default = array())
410
+	{
411
+		return $this->_uri_to_assoc($n, $default, 'rsegment');
412
+	}
413
+
414
+	// --------------------------------------------------------------------
415
+
416
+	/**
417
+	 * Internal URI-to-assoc
418
+	 *
419
+	 * Generates a key/value pair from the URI string or re-routed URI string.
420
+	 *
421
+	 * @used-by	CI_URI::uri_to_assoc()
422
+	 * @used-by	CI_URI::ruri_to_assoc()
423
+	 * @param	int	$n		Index (default: 3)
424
+	 * @param	array	$default	Default values
425
+	 * @param	string	$which		Array name ('segment' or 'rsegment')
426
+	 * @return	array
427
+	 */
428
+	protected function _uri_to_assoc($n = 3, $default = array(), $which = 'segment')
429
+	{
430
+		if ( ! is_numeric($n))
431
+		{
432
+			return $default;
433
+		}
434
+
435
+		if (isset($this->keyval[$which], $this->keyval[$which][$n]))
436
+		{
437
+			return $this->keyval[$which][$n];
438
+		}
439
+
440
+		$total_segments = "total_{$which}s";
441
+		$segment_array = "{$which}_array";
442
+
443
+		if ($this->$total_segments() < $n)
444
+		{
445
+			return (count($default) === 0)
446
+				? array()
447
+				: array_fill_keys($default, NULL);
448
+		}
449
+
450
+		$segments = array_slice($this->$segment_array(), ($n - 1));
451
+		$i = 0;
452
+		$lastval = '';
453
+		$retval = array();
454
+		foreach ($segments as $seg)
455
+		{
456
+			if ($i % 2)
457
+			{
458
+				$retval[$lastval] = $seg;
459
+			}
460
+			else
461
+			{
462
+				$retval[$seg] = NULL;
463
+				$lastval = $seg;
464
+			}
465
+
466
+			$i++;
467
+		}
468
+
469
+		if (count($default) > 0)
470
+		{
471
+			foreach ($default as $val)
472
+			{
473
+				if ( ! array_key_exists($val, $retval))
474
+				{
475
+					$retval[$val] = NULL;
476
+				}
477
+			}
478
+		}
479
+
480
+		// Cache the array for reuse
481
+		isset($this->keyval[$which]) OR $this->keyval[$which] = array();
482
+		$this->keyval[$which][$n] = $retval;
483
+		return $retval;
484
+	}
485
+
486
+	// --------------------------------------------------------------------
487
+
488
+	/**
489
+	 * Assoc to URI
490
+	 *
491
+	 * Generates a URI string from an associative array.
492
+	 *
493
+	 * @param	array	$array	Input array of key/value pairs
494
+	 * @return	string	URI string
495
+	 */
496
+	public function assoc_to_uri($array)
497
+	{
498
+		$temp = array();
499
+		foreach ((array) $array as $key => $val)
500
+		{
501
+			$temp[] = $key;
502
+			$temp[] = $val;
503
+		}
504
+
505
+		return implode('/', $temp);
506
+	}
507
+
508
+	// --------------------------------------------------------------------
509
+
510
+	/**
511
+	 * Slash segment
512
+	 *
513
+	 * Fetches an URI segment with a slash.
514
+	 *
515
+	 * @param	int	$n	Index
516
+	 * @param	string	$where	Where to add the slash ('trailing' or 'leading')
517
+	 * @return	string
518
+	 */
519
+	public function slash_segment($n, $where = 'trailing')
520
+	{
521
+		return $this->_slash_segment($n, $where, 'segment');
522
+	}
523
+
524
+	// --------------------------------------------------------------------
525
+
526
+	/**
527
+	 * Slash routed segment
528
+	 *
529
+	 * Fetches an URI routed segment with a slash.
530
+	 *
531
+	 * @param	int	$n	Index
532
+	 * @param	string	$where	Where to add the slash ('trailing' or 'leading')
533
+	 * @return	string
534
+	 */
535
+	public function slash_rsegment($n, $where = 'trailing')
536
+	{
537
+		return $this->_slash_segment($n, $where, 'rsegment');
538
+	}
539
+
540
+	// --------------------------------------------------------------------
541
+
542
+	/**
543
+	 * Internal Slash segment
544
+	 *
545
+	 * Fetches an URI Segment and adds a slash to it.
546
+	 *
547
+	 * @used-by	CI_URI::slash_segment()
548
+	 * @used-by	CI_URI::slash_rsegment()
549
+	 *
550
+	 * @param	int	$n	Index
551
+	 * @param	string	$where	Where to add the slash ('trailing' or 'leading')
552
+	 * @param	string	$which	Array name ('segment' or 'rsegment')
553
+	 * @return	string
554
+	 */
555
+	protected function _slash_segment($n, $where = 'trailing', $which = 'segment')
556
+	{
557
+		$leading = $trailing = '/';
558
+
559
+		if ($where === 'trailing')
560
+		{
561
+			$leading	= '';
562
+		}
563
+		elseif ($where === 'leading')
564
+		{
565
+			$trailing	= '';
566
+		}
567
+
568
+		return $leading.$this->$which($n).$trailing;
569
+	}
570
+
571
+	// --------------------------------------------------------------------
572
+
573
+	/**
574
+	 * Segment Array
575
+	 *
576
+	 * @return	array	CI_URI::$segments
577
+	 */
578
+	public function segment_array()
579
+	{
580
+		return $this->segments;
581
+	}
582
+
583
+	// --------------------------------------------------------------------
584
+
585
+	/**
586
+	 * Routed Segment Array
587
+	 *
588
+	 * @return	array	CI_URI::$rsegments
589
+	 */
590
+	public function rsegment_array()
591
+	{
592
+		return $this->rsegments;
593
+	}
594
+
595
+	// --------------------------------------------------------------------
596
+
597
+	/**
598
+	 * Total number of segments
599
+	 *
600
+	 * @return	int
601
+	 */
602
+	public function total_segments()
603
+	{
604
+		return count($this->segments);
605
+	}
606
+
607
+	// --------------------------------------------------------------------
608
+
609
+	/**
610
+	 * Total number of routed segments
611
+	 *
612
+	 * @return	int
613
+	 */
614
+	public function total_rsegments()
615
+	{
616
+		return count($this->rsegments);
617
+	}
618
+
619
+	// --------------------------------------------------------------------
620
+
621
+	/**
622
+	 * Fetch URI string
623
+	 *
624
+	 * @return	string	CI_URI::$uri_string
625
+	 */
626
+	public function uri_string()
627
+	{
628
+		return $this->uri_string;
629
+	}
630
+
631
+	// --------------------------------------------------------------------
632
+
633
+	/**
634
+	 * Fetch Re-routed URI string
635
+	 *
636
+	 * @return	string
637
+	 */
638
+	public function ruri_string()
639
+	{
640
+		return ltrim(load_class('Router', 'core')->directory, '/').implode('/', $this->rsegments);
641
+	}
642
+
643
+}

+ 164 - 0
system/core/Utf8.php Datei anzeigen

@@ -0,0 +1,164 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 2.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Utf8 Class
42
+ *
43
+ * Provides support for UTF-8 environments
44
+ *
45
+ * @package		CodeIgniter
46
+ * @subpackage	Libraries
47
+ * @category	UTF-8
48
+ * @author		EllisLab Dev Team
49
+ * @link		https://codeigniter.com/user_guide/libraries/utf8.html
50
+ */
51
+class CI_Utf8 {
52
+
53
+	/**
54
+	 * Class constructor
55
+	 *
56
+	 * Determines if UTF-8 support is to be enabled.
57
+	 *
58
+	 * @return	void
59
+	 */
60
+	public function __construct()
61
+	{
62
+		if (
63
+			defined('PREG_BAD_UTF8_ERROR')				// PCRE must support UTF-8
64
+			&& (ICONV_ENABLED === TRUE OR MB_ENABLED === TRUE)	// iconv or mbstring must be installed
65
+			&& strtoupper(config_item('charset')) === 'UTF-8'	// Application charset must be UTF-8
66
+			)
67
+		{
68
+			define('UTF8_ENABLED', TRUE);
69
+			log_message('debug', 'UTF-8 Support Enabled');
70
+		}
71
+		else
72
+		{
73
+			define('UTF8_ENABLED', FALSE);
74
+			log_message('debug', 'UTF-8 Support Disabled');
75
+		}
76
+
77
+		log_message('info', 'Utf8 Class Initialized');
78
+	}
79
+
80
+	// --------------------------------------------------------------------
81
+
82
+	/**
83
+	 * Clean UTF-8 strings
84
+	 *
85
+	 * Ensures strings contain only valid UTF-8 characters.
86
+	 *
87
+	 * @param	string	$str	String to clean
88
+	 * @return	string
89
+	 */
90
+	public function clean_string($str)
91
+	{
92
+		if ($this->is_ascii($str) === FALSE)
93
+		{
94
+			if (MB_ENABLED)
95
+			{
96
+				$str = mb_convert_encoding($str, 'UTF-8', 'UTF-8');
97
+			}
98
+			elseif (ICONV_ENABLED)
99
+			{
100
+				$str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
101
+			}
102
+		}
103
+
104
+		return $str;
105
+	}
106
+
107
+	// --------------------------------------------------------------------
108
+
109
+	/**
110
+	 * Remove ASCII control characters
111
+	 *
112
+	 * Removes all ASCII control characters except horizontal tabs,
113
+	 * line feeds, and carriage returns, as all others can cause
114
+	 * problems in XML.
115
+	 *
116
+	 * @param	string	$str	String to clean
117
+	 * @return	string
118
+	 */
119
+	public function safe_ascii_for_xml($str)
120
+	{
121
+		return remove_invisible_characters($str, FALSE);
122
+	}
123
+
124
+	// --------------------------------------------------------------------
125
+
126
+	/**
127
+	 * Convert to UTF-8
128
+	 *
129
+	 * Attempts to convert a string to UTF-8.
130
+	 *
131
+	 * @param	string	$str		Input string
132
+	 * @param	string	$encoding	Input encoding
133
+	 * @return	string	$str encoded in UTF-8 or FALSE on failure
134
+	 */
135
+	public function convert_to_utf8($str, $encoding)
136
+	{
137
+		if (MB_ENABLED)
138
+		{
139
+			return mb_convert_encoding($str, 'UTF-8', $encoding);
140
+		}
141
+		elseif (ICONV_ENABLED)
142
+		{
143
+			return @iconv($encoding, 'UTF-8', $str);
144
+		}
145
+
146
+		return FALSE;
147
+	}
148
+
149
+	// --------------------------------------------------------------------
150
+
151
+	/**
152
+	 * Is ASCII?
153
+	 *
154
+	 * Tests if a string is standard 7-bit ASCII or not.
155
+	 *
156
+	 * @param	string	$str	String to check
157
+	 * @return	bool
158
+	 */
159
+	public function is_ascii($str)
160
+	{
161
+		return (preg_match('/[^\x00-\x7F]/S', $str) === 0);
162
+	}
163
+
164
+}

+ 254 - 0
system/core/compat/hash.php Datei anzeigen

@@ -0,0 +1,254 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 3.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * PHP ext/hash compatibility package
42
+ *
43
+ * @package		CodeIgniter
44
+ * @subpackage	CodeIgniter
45
+ * @category	Compatibility
46
+ * @author		Andrey Andreev
47
+ * @link		https://codeigniter.com/user_guide/
48
+ * @link		http://php.net/hash
49
+ */
50
+
51
+// ------------------------------------------------------------------------
52
+
53
+if (is_php('5.6'))
54
+{
55
+	return;
56
+}
57
+
58
+// ------------------------------------------------------------------------
59
+
60
+if ( ! function_exists('hash_equals'))
61
+{
62
+	/**
63
+	 * hash_equals()
64
+	 *
65
+	 * @link	http://php.net/hash_equals
66
+	 * @param	string	$known_string
67
+	 * @param	string	$user_string
68
+	 * @return	bool
69
+	 */
70
+	function hash_equals($known_string, $user_string)
71
+	{
72
+		if ( ! is_string($known_string))
73
+		{
74
+			trigger_error('hash_equals(): Expected known_string to be a string, '.strtolower(gettype($known_string)).' given', E_USER_WARNING);
75
+			return FALSE;
76
+		}
77
+		elseif ( ! is_string($user_string))
78
+		{
79
+			trigger_error('hash_equals(): Expected user_string to be a string, '.strtolower(gettype($user_string)).' given', E_USER_WARNING);
80
+			return FALSE;
81
+		}
82
+		elseif (($length = strlen($known_string)) !== strlen($user_string))
83
+		{
84
+			return FALSE;
85
+		}
86
+
87
+		$diff = 0;
88
+		for ($i = 0; $i < $length; $i++)
89
+		{
90
+			$diff |= ord($known_string[$i]) ^ ord($user_string[$i]);
91
+		}
92
+
93
+		return ($diff === 0);
94
+	}
95
+}
96
+
97
+// ------------------------------------------------------------------------
98
+
99
+if (is_php('5.5'))
100
+{
101
+	return;
102
+}
103
+
104
+// ------------------------------------------------------------------------
105
+
106
+if ( ! function_exists('hash_pbkdf2'))
107
+{
108
+	/**
109
+	 * hash_pbkdf2()
110
+	 *
111
+	 * @link	http://php.net/hash_pbkdf2
112
+	 * @param	string	$algo
113
+	 * @param	string	$password
114
+	 * @param	string	$salt
115
+	 * @param	int	$iterations
116
+	 * @param	int	$length
117
+	 * @param	bool	$raw_output
118
+	 * @return	string
119
+	 */
120
+	function hash_pbkdf2($algo, $password, $salt, $iterations, $length = 0, $raw_output = FALSE)
121
+	{
122
+		if ( ! in_array(strtolower($algo), hash_algos(), TRUE))
123
+		{
124
+			trigger_error('hash_pbkdf2(): Unknown hashing algorithm: '.$algo, E_USER_WARNING);
125
+			return FALSE;
126
+		}
127
+
128
+		if (($type = gettype($iterations)) !== 'integer')
129
+		{
130
+			if ($type === 'object' && method_exists($iterations, '__toString'))
131
+			{
132
+				$iterations = (string) $iterations;
133
+			}
134
+
135
+			if (is_string($iterations) && is_numeric($iterations))
136
+			{
137
+				$iterations = (int) $iterations;
138
+			}
139
+			else
140
+			{
141
+				trigger_error('hash_pbkdf2() expects parameter 4 to be long, '.$type.' given', E_USER_WARNING);
142
+				return NULL;
143
+			}
144
+		}
145
+
146
+		if ($iterations < 1)
147
+		{
148
+			trigger_error('hash_pbkdf2(): Iterations must be a positive integer: '.$iterations, E_USER_WARNING);
149
+			return FALSE;
150
+		}
151
+
152
+		if (($type = gettype($length)) !== 'integer')
153
+		{
154
+			if ($type === 'object' && method_exists($length, '__toString'))
155
+			{
156
+				$length = (string) $length;
157
+			}
158
+
159
+			if (is_string($length) && is_numeric($length))
160
+			{
161
+				$length = (int) $length;
162
+			}
163
+			else
164
+			{
165
+				trigger_error('hash_pbkdf2() expects parameter 5 to be long, '.$type.' given', E_USER_WARNING);
166
+				return NULL;
167
+			}
168
+		}
169
+
170
+		if ($length < 0)
171
+		{
172
+			trigger_error('hash_pbkdf2(): Length must be greater than or equal to 0: '.$length, E_USER_WARNING);
173
+			return FALSE;
174
+		}
175
+
176
+		$hash_length = defined('MB_OVERLOAD_STRING')
177
+			? mb_strlen(hash($algo, NULL, TRUE), '8bit')
178
+			: strlen(hash($algo, NULL, TRUE));
179
+		empty($length) && $length = $hash_length;
180
+
181
+		// Pre-hash password inputs longer than the algorithm's block size
182
+		// (i.e. prepare HMAC key) to mitigate potential DoS attacks.
183
+		static $block_sizes;
184
+		empty($block_sizes) && $block_sizes = array(
185
+			'gost' => 32,
186
+			'haval128,3' => 128,
187
+			'haval160,3' => 128,
188
+			'haval192,3' => 128,
189
+			'haval224,3' => 128,
190
+			'haval256,3' => 128,
191
+			'haval128,4' => 128,
192
+			'haval160,4' => 128,
193
+			'haval192,4' => 128,
194
+			'haval224,4' => 128,
195
+			'haval256,4' => 128,
196
+			'haval128,5' => 128,
197
+			'haval160,5' => 128,
198
+			'haval192,5' => 128,
199
+			'haval224,5' => 128,
200
+			'haval256,5' => 128,
201
+			'md2' => 16,
202
+			'md4' => 64,
203
+			'md5' => 64,
204
+			'ripemd128' => 64,
205
+			'ripemd160' => 64,
206
+			'ripemd256' => 64,
207
+			'ripemd320' => 64,
208
+			'salsa10' => 64,
209
+			'salsa20' => 64,
210
+			'sha1' => 64,
211
+			'sha224' => 64,
212
+			'sha256' => 64,
213
+			'sha384' => 128,
214
+			'sha512' => 128,
215
+			'snefru' => 32,
216
+			'snefru256' => 32,
217
+			'tiger128,3' => 64,
218
+			'tiger160,3' => 64,
219
+			'tiger192,3' => 64,
220
+			'tiger128,4' => 64,
221
+			'tiger160,4' => 64,
222
+			'tiger192,4' => 64,
223
+			'whirlpool' => 64
224
+		);
225
+
226
+		if (isset($block_sizes[$algo], $password[$block_sizes[$algo]]))
227
+		{
228
+			$password = hash($algo, $password, TRUE);
229
+		}
230
+
231
+		$hash = '';
232
+		// Note: Blocks are NOT 0-indexed
233
+		for ($bc = (int) ceil($length / $hash_length), $bi = 1; $bi <= $bc; $bi++)
234
+		{
235
+			$key = $derived_key = hash_hmac($algo, $salt.pack('N', $bi), $password, TRUE);
236
+			for ($i = 1; $i < $iterations; $i++)
237
+			{
238
+				$derived_key ^= $key = hash_hmac($algo, $key, $password, TRUE);
239
+			}
240
+
241
+			$hash .= $derived_key;
242
+		}
243
+
244
+		// This is not RFC-compatible, but we're aiming for natural PHP compatibility
245
+		if ( ! $raw_output)
246
+		{
247
+			$hash = bin2hex($hash);
248
+		}
249
+
250
+		return defined('MB_OVERLOAD_STRING')
251
+			? mb_substr($hash, 0, $length, '8bit')
252
+			: substr($hash, 0, $length);
253
+	}
254
+}

+ 11 - 0
system/core/compat/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 149 - 0
system/core/compat/mbstring.php Datei anzeigen

@@ -0,0 +1,149 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 3.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * PHP ext/mbstring compatibility package
42
+ *
43
+ * @package		CodeIgniter
44
+ * @subpackage	CodeIgniter
45
+ * @category	Compatibility
46
+ * @author		Andrey Andreev
47
+ * @link		https://codeigniter.com/user_guide/
48
+ * @link		http://php.net/mbstring
49
+ */
50
+
51
+// ------------------------------------------------------------------------
52
+
53
+if (MB_ENABLED === TRUE)
54
+{
55
+	return;
56
+}
57
+
58
+// ------------------------------------------------------------------------
59
+
60
+if ( ! function_exists('mb_strlen'))
61
+{
62
+	/**
63
+	 * mb_strlen()
64
+	 *
65
+	 * WARNING: This function WILL fall-back to strlen()
66
+	 * if iconv is not available!
67
+	 *
68
+	 * @link	http://php.net/mb_strlen
69
+	 * @param	string	$str
70
+	 * @param	string	$encoding
71
+	 * @return	int
72
+	 */
73
+	function mb_strlen($str, $encoding = NULL)
74
+	{
75
+		if (ICONV_ENABLED === TRUE)
76
+		{
77
+			return iconv_strlen($str, isset($encoding) ? $encoding : config_item('charset'));
78
+		}
79
+
80
+		log_message('debug', 'Compatibility (mbstring): iconv_strlen() is not available, falling back to strlen().');
81
+		return strlen($str);
82
+	}
83
+}
84
+
85
+// ------------------------------------------------------------------------
86
+
87
+if ( ! function_exists('mb_strpos'))
88
+{
89
+	/**
90
+	 * mb_strpos()
91
+	 *
92
+	 * WARNING: This function WILL fall-back to strpos()
93
+	 * if iconv is not available!
94
+	 *
95
+	 * @link	http://php.net/mb_strpos
96
+	 * @param	string	$haystack
97
+	 * @param	string	$needle
98
+	 * @param	int	$offset
99
+	 * @param	string	$encoding
100
+	 * @return	mixed
101
+	 */
102
+	function mb_strpos($haystack, $needle, $offset = 0, $encoding = NULL)
103
+	{
104
+		if (ICONV_ENABLED === TRUE)
105
+		{
106
+			return iconv_strpos($haystack, $needle, $offset, isset($encoding) ? $encoding : config_item('charset'));
107
+		}
108
+
109
+		log_message('debug', 'Compatibility (mbstring): iconv_strpos() is not available, falling back to strpos().');
110
+		return strpos($haystack, $needle, $offset);
111
+	}
112
+}
113
+
114
+// ------------------------------------------------------------------------
115
+
116
+if ( ! function_exists('mb_substr'))
117
+{
118
+	/**
119
+	 * mb_substr()
120
+	 *
121
+	 * WARNING: This function WILL fall-back to substr()
122
+	 * if iconv is not available.
123
+	 *
124
+	 * @link	http://php.net/mb_substr
125
+	 * @param	string	$str
126
+	 * @param	int	$start
127
+	 * @param	int 	$length
128
+	 * @param	string	$encoding
129
+	 * @return	string
130
+	 */
131
+	function mb_substr($str, $start, $length = NULL, $encoding = NULL)
132
+	{
133
+		if (ICONV_ENABLED === TRUE)
134
+		{
135
+			isset($encoding) OR $encoding = config_item('charset');
136
+			return iconv_substr(
137
+				$str,
138
+				$start,
139
+				isset($length) ? $length : iconv_strlen($str, $encoding), // NULL doesn't work
140
+				$encoding
141
+			);
142
+		}
143
+
144
+		log_message('debug', 'Compatibility (mbstring): iconv_substr() is not available, falling back to substr().');
145
+		return isset($length)
146
+			? substr($str, $start, $length)
147
+			: substr($str, $start);
148
+	}
149
+}

+ 251 - 0
system/core/compat/password.php Datei anzeigen

@@ -0,0 +1,251 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 3.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * PHP ext/standard/password compatibility package
42
+ *
43
+ * @package		CodeIgniter
44
+ * @subpackage	CodeIgniter
45
+ * @category	Compatibility
46
+ * @author		Andrey Andreev
47
+ * @link		https://codeigniter.com/user_guide/
48
+ * @link		http://php.net/password
49
+ */
50
+
51
+// ------------------------------------------------------------------------
52
+
53
+if (is_php('5.5') OR ! defined('CRYPT_BLOWFISH') OR CRYPT_BLOWFISH !== 1 OR defined('HHVM_VERSION'))
54
+{
55
+	return;
56
+}
57
+
58
+// ------------------------------------------------------------------------
59
+
60
+defined('PASSWORD_BCRYPT') OR define('PASSWORD_BCRYPT', 1);
61
+defined('PASSWORD_DEFAULT') OR define('PASSWORD_DEFAULT', PASSWORD_BCRYPT);
62
+
63
+// ------------------------------------------------------------------------
64
+
65
+if ( ! function_exists('password_get_info'))
66
+{
67
+	/**
68
+	 * password_get_info()
69
+	 *
70
+	 * @link	http://php.net/password_get_info
71
+	 * @param	string	$hash
72
+	 * @return	array
73
+	 */
74
+	function password_get_info($hash)
75
+	{
76
+		return (strlen($hash) < 60 OR sscanf($hash, '$2y$%d', $hash) !== 1)
77
+			? array('algo' => 0, 'algoName' => 'unknown', 'options' => array())
78
+			: array('algo' => 1, 'algoName' => 'bcrypt', 'options' => array('cost' => $hash));
79
+	}
80
+}
81
+
82
+// ------------------------------------------------------------------------
83
+
84
+if ( ! function_exists('password_hash'))
85
+{
86
+	/**
87
+	 * password_hash()
88
+	 *
89
+	 * @link	http://php.net/password_hash
90
+	 * @param	string	$password
91
+	 * @param	int	$algo
92
+	 * @param	array	$options
93
+	 * @return	mixed
94
+	 */
95
+	function password_hash($password, $algo, array $options = array())
96
+	{
97
+		static $func_overload;
98
+		isset($func_overload) OR $func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
99
+
100
+		if ($algo !== 1)
101
+		{
102
+			trigger_error('password_hash(): Unknown hashing algorithm: '.(int) $algo, E_USER_WARNING);
103
+			return NULL;
104
+		}
105
+
106
+		if (isset($options['cost']) && ($options['cost'] < 4 OR $options['cost'] > 31))
107
+		{
108
+			trigger_error('password_hash(): Invalid bcrypt cost parameter specified: '.(int) $options['cost'], E_USER_WARNING);
109
+			return NULL;
110
+		}
111
+
112
+		if (isset($options['salt']) && ($saltlen = ($func_overload ? mb_strlen($options['salt'], '8bit') : strlen($options['salt']))) < 22)
113
+		{
114
+			trigger_error('password_hash(): Provided salt is too short: '.$saltlen.' expecting 22', E_USER_WARNING);
115
+			return NULL;
116
+		}
117
+		elseif ( ! isset($options['salt']))
118
+		{
119
+			if (function_exists('random_bytes'))
120
+			{
121
+				try
122
+				{
123
+					$options['salt'] = random_bytes(16);
124
+				}
125
+				catch (Exception $e)
126
+				{
127
+					log_message('error', 'compat/password: Error while trying to use random_bytes(): '.$e->getMessage());
128
+					return FALSE;
129
+				}
130
+			}
131
+			elseif (defined('MCRYPT_DEV_URANDOM'))
132
+			{
133
+				$options['salt'] = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM);
134
+			}
135
+			elseif (DIRECTORY_SEPARATOR === '/' && (is_readable($dev = '/dev/arandom') OR is_readable($dev = '/dev/urandom')))
136
+			{
137
+				if (($fp = fopen($dev, 'rb')) === FALSE)
138
+				{
139
+					log_message('error', 'compat/password: Unable to open '.$dev.' for reading.');
140
+					return FALSE;
141
+				}
142
+
143
+				// Try not to waste entropy ...
144
+				is_php('5.4') && stream_set_chunk_size($fp, 16);
145
+
146
+				$options['salt'] = '';
147
+				for ($read = 0; $read < 16; $read = ($func_overload) ? mb_strlen($options['salt'], '8bit') : strlen($options['salt']))
148
+				{
149
+					if (($read = fread($fp, 16 - $read)) === FALSE)
150
+					{
151
+						log_message('error', 'compat/password: Error while reading from '.$dev.'.');
152
+						return FALSE;
153
+					}
154
+					$options['salt'] .= $read;
155
+				}
156
+
157
+				fclose($fp);
158
+			}
159
+			elseif (function_exists('openssl_random_pseudo_bytes'))
160
+			{
161
+				$is_secure = NULL;
162
+				$options['salt'] = openssl_random_pseudo_bytes(16, $is_secure);
163
+				if ($is_secure !== TRUE)
164
+				{
165
+					log_message('error', 'compat/password: openssl_random_pseudo_bytes() set the $cryto_strong flag to FALSE');
166
+					return FALSE;
167
+				}
168
+			}
169
+			else
170
+			{
171
+				log_message('error', 'compat/password: No CSPRNG available.');
172
+				return FALSE;
173
+			}
174
+
175
+			$options['salt'] = str_replace('+', '.', rtrim(base64_encode($options['salt']), '='));
176
+		}
177
+		elseif ( ! preg_match('#^[a-zA-Z0-9./]+$#D', $options['salt']))
178
+		{
179
+			$options['salt'] = str_replace('+', '.', rtrim(base64_encode($options['salt']), '='));
180
+		}
181
+
182
+		isset($options['cost']) OR $options['cost'] = 10;
183
+
184
+		return (strlen($password = crypt($password, sprintf('$2y$%02d$%s', $options['cost'], $options['salt']))) === 60)
185
+			? $password
186
+			: FALSE;
187
+	}
188
+}
189
+
190
+// ------------------------------------------------------------------------
191
+
192
+if ( ! function_exists('password_needs_rehash'))
193
+{
194
+	/**
195
+	 * password_needs_rehash()
196
+	 *
197
+	 * @link	http://php.net/password_needs_rehash
198
+	 * @param	string	$hash
199
+	 * @param	int	$algo
200
+	 * @param	array	$options
201
+	 * @return	bool
202
+	 */
203
+	function password_needs_rehash($hash, $algo, array $options = array())
204
+	{
205
+		$info = password_get_info($hash);
206
+
207
+		if ($algo !== $info['algo'])
208
+		{
209
+			return TRUE;
210
+		}
211
+		elseif ($algo === 1)
212
+		{
213
+			$options['cost'] = isset($options['cost']) ? (int) $options['cost'] : 10;
214
+			return ($info['options']['cost'] !== $options['cost']);
215
+		}
216
+
217
+		// Odd at first glance, but according to a comment in PHP's own unit tests,
218
+		// because it is an unknown algorithm - it's valid and therefore doesn't
219
+		// need rehashing.
220
+		return FALSE;
221
+	}
222
+}
223
+
224
+// ------------------------------------------------------------------------
225
+
226
+if ( ! function_exists('password_verify'))
227
+{
228
+	/**
229
+	 * password_verify()
230
+	 *
231
+	 * @link	http://php.net/password_verify
232
+	 * @param	string	$password
233
+	 * @param	string	$hash
234
+	 * @return	bool
235
+	 */
236
+	function password_verify($password, $hash)
237
+	{
238
+		if (strlen($hash) !== 60 OR strlen($password = crypt($password, $hash)) !== 60)
239
+		{
240
+			return FALSE;
241
+		}
242
+
243
+		$compare = 0;
244
+		for ($i = 0; $i < 60; $i++)
245
+		{
246
+			$compare |= (ord($password[$i]) ^ ord($hash[$i]));
247
+		}
248
+
249
+		return ($compare === 0);
250
+	}
251
+}

+ 182 - 0
system/core/compat/standard.php Datei anzeigen

@@ -0,0 +1,182 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 3.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * PHP ext/standard compatibility package
42
+ *
43
+ * @package		CodeIgniter
44
+ * @subpackage	CodeIgniter
45
+ * @category	Compatibility
46
+ * @author		Andrey Andreev
47
+ * @link		https://codeigniter.com/user_guide/
48
+ */
49
+
50
+// ------------------------------------------------------------------------
51
+
52
+if (is_php('5.5'))
53
+{
54
+	return;
55
+}
56
+
57
+// ------------------------------------------------------------------------
58
+
59
+if ( ! function_exists('array_column'))
60
+{
61
+	/**
62
+	 * array_column()
63
+	 *
64
+	 * @link	http://php.net/array_column
65
+	 * @param	array	$array
66
+	 * @param	mixed	$column_key
67
+	 * @param	mixed	$index_key
68
+	 * @return	array
69
+	 */
70
+	function array_column(array $array, $column_key, $index_key = NULL)
71
+	{
72
+		if ( ! in_array($type = gettype($column_key), array('integer', 'string', 'NULL'), TRUE))
73
+		{
74
+			if ($type === 'double')
75
+			{
76
+				$column_key = (int) $column_key;
77
+			}
78
+			elseif ($type === 'object' && method_exists($column_key, '__toString'))
79
+			{
80
+				$column_key = (string) $column_key;
81
+			}
82
+			else
83
+			{
84
+				trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING);
85
+				return FALSE;
86
+			}
87
+		}
88
+
89
+		if ( ! in_array($type = gettype($index_key), array('integer', 'string', 'NULL'), TRUE))
90
+		{
91
+			if ($type === 'double')
92
+			{
93
+				$index_key = (int) $index_key;
94
+			}
95
+			elseif ($type === 'object' && method_exists($index_key, '__toString'))
96
+			{
97
+				$index_key = (string) $index_key;
98
+			}
99
+			else
100
+			{
101
+				trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING);
102
+				return FALSE;
103
+			}
104
+		}
105
+
106
+		$result = array();
107
+		foreach ($array as &$a)
108
+		{
109
+			if ($column_key === NULL)
110
+			{
111
+				$value = $a;
112
+			}
113
+			elseif (is_array($a) && array_key_exists($column_key, $a))
114
+			{
115
+				$value = $a[$column_key];
116
+			}
117
+			else
118
+			{
119
+				continue;
120
+			}
121
+
122
+			if ($index_key === NULL OR ! array_key_exists($index_key, $a))
123
+			{
124
+				$result[] = $value;
125
+			}
126
+			else
127
+			{
128
+				$result[$a[$index_key]] = $value;
129
+			}
130
+		}
131
+
132
+		return $result;
133
+	}
134
+}
135
+
136
+// ------------------------------------------------------------------------
137
+
138
+if (is_php('5.4'))
139
+{
140
+	return;
141
+}
142
+
143
+// ------------------------------------------------------------------------
144
+
145
+if ( ! function_exists('hex2bin'))
146
+{
147
+	/**
148
+	 * hex2bin()
149
+	 *
150
+	 * @link	http://php.net/hex2bin
151
+	 * @param	string	$data
152
+	 * @return	string
153
+	 */
154
+	function hex2bin($data)
155
+	{
156
+		if (in_array($type = gettype($data), array('array', 'double', 'object', 'resource'), TRUE))
157
+		{
158
+			if ($type === 'object' && method_exists($data, '__toString'))
159
+			{
160
+				$data = (string) $data;
161
+			}
162
+			else
163
+			{
164
+				trigger_error('hex2bin() expects parameter 1 to be string, '.$type.' given', E_USER_WARNING);
165
+				return NULL;
166
+			}
167
+		}
168
+
169
+		if (strlen($data) % 2 !== 0)
170
+		{
171
+			trigger_error('Hexadecimal input string must have an even length', E_USER_WARNING);
172
+			return FALSE;
173
+		}
174
+		elseif ( ! preg_match('/^[0-9a-f]*$/i', $data))
175
+		{
176
+			trigger_error('Input string must be hexadecimal string', E_USER_WARNING);
177
+			return FALSE;
178
+		}
179
+
180
+		return pack('H*', $data);
181
+	}
182
+}

+ 11 - 0
system/core/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 218 - 0
system/database/DB.php Datei anzeigen

@@ -0,0 +1,218 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Initialize the database
42
+ *
43
+ * @category	Database
44
+ * @author	EllisLab Dev Team
45
+ * @link	https://codeigniter.com/user_guide/database/
46
+ *
47
+ * @param 	string|string[]	$params
48
+ * @param 	bool		$query_builder_override
49
+ *				Determines if query builder should be used or not
50
+ */
51
+function &DB($params = '', $query_builder_override = NULL)
52
+{
53
+	// Load the DB config file if a DSN string wasn't passed
54
+	if (is_string($params) && strpos($params, '://') === FALSE)
55
+	{
56
+		// Is the config file in the environment folder?
57
+		if ( ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php')
58
+			&& ! file_exists($file_path = APPPATH.'config/database.php'))
59
+		{
60
+			show_error('The configuration file database.php does not exist.');
61
+		}
62
+
63
+		include($file_path);
64
+
65
+		// Make packages contain database config files,
66
+		// given that the controller instance already exists
67
+		if (class_exists('CI_Controller', FALSE))
68
+		{
69
+			foreach (get_instance()->load->get_package_paths() as $path)
70
+			{
71
+				if ($path !== APPPATH)
72
+				{
73
+					if (file_exists($file_path = $path.'config/'.ENVIRONMENT.'/database.php'))
74
+					{
75
+						include($file_path);
76
+					}
77
+					elseif (file_exists($file_path = $path.'config/database.php'))
78
+					{
79
+						include($file_path);
80
+					}
81
+				}
82
+			}
83
+		}
84
+
85
+		if ( ! isset($db) OR count($db) === 0)
86
+		{
87
+			show_error('No database connection settings were found in the database config file.');
88
+		}
89
+
90
+		if ($params !== '')
91
+		{
92
+			$active_group = $params;
93
+		}
94
+
95
+		if ( ! isset($active_group))
96
+		{
97
+			show_error('You have not specified a database connection group via $active_group in your config/database.php file.');
98
+		}
99
+		elseif ( ! isset($db[$active_group]))
100
+		{
101
+			show_error('You have specified an invalid database connection group ('.$active_group.') in your config/database.php file.');
102
+		}
103
+
104
+		$params = $db[$active_group];
105
+	}
106
+	elseif (is_string($params))
107
+	{
108
+		/**
109
+		 * Parse the URL from the DSN string
110
+		 * Database settings can be passed as discreet
111
+		 * parameters or as a data source name in the first
112
+		 * parameter. DSNs must have this prototype:
113
+		 * $dsn = 'driver://username:password@hostname/database';
114
+		 */
115
+		if (($dsn = @parse_url($params)) === FALSE)
116
+		{
117
+			show_error('Invalid DB Connection String');
118
+		}
119
+
120
+		$params = array(
121
+			'dbdriver'	=> $dsn['scheme'],
122
+			'hostname'	=> isset($dsn['host']) ? rawurldecode($dsn['host']) : '',
123
+			'port'		=> isset($dsn['port']) ? rawurldecode($dsn['port']) : '',
124
+			'username'	=> isset($dsn['user']) ? rawurldecode($dsn['user']) : '',
125
+			'password'	=> isset($dsn['pass']) ? rawurldecode($dsn['pass']) : '',
126
+			'database'	=> isset($dsn['path']) ? rawurldecode(substr($dsn['path'], 1)) : ''
127
+		);
128
+
129
+		// Were additional config items set?
130
+		if (isset($dsn['query']))
131
+		{
132
+			parse_str($dsn['query'], $extra);
133
+
134
+			foreach ($extra as $key => $val)
135
+			{
136
+				if (is_string($val) && in_array(strtoupper($val), array('TRUE', 'FALSE', 'NULL')))
137
+				{
138
+					$val = var_export($val, TRUE);
139
+				}
140
+
141
+				$params[$key] = $val;
142
+			}
143
+		}
144
+	}
145
+
146
+	// No DB specified yet? Beat them senseless...
147
+	if (empty($params['dbdriver']))
148
+	{
149
+		show_error('You have not selected a database type to connect to.');
150
+	}
151
+
152
+	// Load the DB classes. Note: Since the query builder class is optional
153
+	// we need to dynamically create a class that extends proper parent class
154
+	// based on whether we're using the query builder class or not.
155
+	if ($query_builder_override !== NULL)
156
+	{
157
+		$query_builder = $query_builder_override;
158
+	}
159
+	// Backwards compatibility work-around for keeping the
160
+	// $active_record config variable working. Should be
161
+	// removed in v3.1
162
+	elseif ( ! isset($query_builder) && isset($active_record))
163
+	{
164
+		$query_builder = $active_record;
165
+	}
166
+
167
+	require_once(BASEPATH.'database/DB_driver.php');
168
+
169
+	if ( ! isset($query_builder) OR $query_builder === TRUE)
170
+	{
171
+		require_once(BASEPATH.'database/DB_query_builder.php');
172
+		if ( ! class_exists('CI_DB', FALSE))
173
+		{
174
+			/**
175
+			 * CI_DB
176
+			 *
177
+			 * Acts as an alias for both CI_DB_driver and CI_DB_query_builder.
178
+			 *
179
+			 * @see	CI_DB_query_builder
180
+			 * @see	CI_DB_driver
181
+			 */
182
+			class CI_DB extends CI_DB_query_builder { }
183
+		}
184
+	}
185
+	elseif ( ! class_exists('CI_DB', FALSE))
186
+	{
187
+		/**
188
+	 	 * @ignore
189
+		 */
190
+		class CI_DB extends CI_DB_driver { }
191
+	}
192
+
193
+	// Load the DB driver
194
+	$driver_file = BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php';
195
+
196
+	file_exists($driver_file) OR show_error('Invalid DB driver');
197
+	require_once($driver_file);
198
+
199
+	// Instantiate the DB adapter
200
+	$driver = 'CI_DB_'.$params['dbdriver'].'_driver';
201
+	$DB = new $driver($params);
202
+
203
+	// Check for a subdriver
204
+	if ( ! empty($DB->subdriver))
205
+	{
206
+		$driver_file = BASEPATH.'database/drivers/'.$DB->dbdriver.'/subdrivers/'.$DB->dbdriver.'_'.$DB->subdriver.'_driver.php';
207
+
208
+		if (file_exists($driver_file))
209
+		{
210
+			require_once($driver_file);
211
+			$driver = 'CI_DB_'.$DB->dbdriver.'_'.$DB->subdriver.'_driver';
212
+			$DB = new $driver($params);
213
+		}
214
+	}
215
+
216
+	$DB->initialize();
217
+	return $DB;
218
+}

+ 221 - 0
system/database/DB_cache.php Datei anzeigen

@@ -0,0 +1,221 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Database Cache Class
42
+ *
43
+ * @category	Database
44
+ * @author		EllisLab Dev Team
45
+ * @link		https://codeigniter.com/user_guide/database/
46
+ */
47
+class CI_DB_Cache {
48
+
49
+	/**
50
+	 * CI Singleton
51
+	 *
52
+	 * @var	object
53
+	 */
54
+	public $CI;
55
+
56
+	/**
57
+	 * Database object
58
+	 *
59
+	 * Allows passing of DB object so that multiple database connections
60
+	 * and returned DB objects can be supported.
61
+	 *
62
+	 * @var	object
63
+	 */
64
+	public $db;
65
+
66
+	// --------------------------------------------------------------------
67
+
68
+	/**
69
+	 * Constructor
70
+	 *
71
+	 * @param	object	&$db
72
+	 * @return	void
73
+	 */
74
+	public function __construct(&$db)
75
+	{
76
+		// Assign the main CI object to $this->CI and load the file helper since we use it a lot
77
+		$this->CI =& get_instance();
78
+		$this->db =& $db;
79
+		$this->CI->load->helper('file');
80
+
81
+		$this->check_path();
82
+	}
83
+
84
+	// --------------------------------------------------------------------
85
+
86
+	/**
87
+	 * Set Cache Directory Path
88
+	 *
89
+	 * @param	string	$path	Path to the cache directory
90
+	 * @return	bool
91
+	 */
92
+	public function check_path($path = '')
93
+	{
94
+		if ($path === '')
95
+		{
96
+			if ($this->db->cachedir === '')
97
+			{
98
+				return $this->db->cache_off();
99
+			}
100
+
101
+			$path = $this->db->cachedir;
102
+		}
103
+
104
+		// Add a trailing slash to the path if needed
105
+		$path = realpath($path)
106
+			? rtrim(realpath($path), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR
107
+			: rtrim($path, '/').'/';
108
+
109
+		if ( ! is_dir($path))
110
+		{
111
+			log_message('debug', 'DB cache path error: '.$path);
112
+
113
+			// If the path is wrong we'll turn off caching
114
+			return $this->db->cache_off();
115
+		}
116
+
117
+		if ( ! is_really_writable($path))
118
+		{
119
+			log_message('debug', 'DB cache dir not writable: '.$path);
120
+
121
+			// If the path is not really writable we'll turn off caching
122
+			return $this->db->cache_off();
123
+		}
124
+
125
+		$this->db->cachedir = $path;
126
+		return TRUE;
127
+	}
128
+
129
+	// --------------------------------------------------------------------
130
+
131
+	/**
132
+	 * Retrieve a cached query
133
+	 *
134
+	 * The URI being requested will become the name of the cache sub-folder.
135
+	 * An MD5 hash of the SQL statement will become the cache file name.
136
+	 *
137
+	 * @param	string	$sql
138
+	 * @return	string
139
+	 */
140
+	public function read($sql)
141
+	{
142
+		$segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
143
+		$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
144
+		$filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql);
145
+
146
+		if ( ! is_file($filepath) OR FALSE === ($cachedata = file_get_contents($filepath)))
147
+		{
148
+			return FALSE;
149
+		}
150
+
151
+		return unserialize($cachedata);
152
+	}
153
+
154
+	// --------------------------------------------------------------------
155
+
156
+	/**
157
+	 * Write a query to a cache file
158
+	 *
159
+	 * @param	string	$sql
160
+	 * @param	object	$object
161
+	 * @return	bool
162
+	 */
163
+	public function write($sql, $object)
164
+	{
165
+		$segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
166
+		$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
167
+		$dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';
168
+		$filename = md5($sql);
169
+
170
+		if ( ! is_dir($dir_path) && ! @mkdir($dir_path, 0750))
171
+		{
172
+			return FALSE;
173
+		}
174
+
175
+		if (write_file($dir_path.$filename, serialize($object)) === FALSE)
176
+		{
177
+			return FALSE;
178
+		}
179
+
180
+		chmod($dir_path.$filename, 0640);
181
+		return TRUE;
182
+	}
183
+
184
+	// --------------------------------------------------------------------
185
+
186
+	/**
187
+	 * Delete cache files within a particular directory
188
+	 *
189
+	 * @param	string	$segment_one
190
+	 * @param	string	$segment_two
191
+	 * @return	void
192
+	 */
193
+	public function delete($segment_one = '', $segment_two = '')
194
+	{
195
+		if ($segment_one === '')
196
+		{
197
+			$segment_one  = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1);
198
+		}
199
+
200
+		if ($segment_two === '')
201
+		{
202
+			$segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2);
203
+		}
204
+
205
+		$dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/';
206
+		delete_files($dir_path, TRUE);
207
+	}
208
+
209
+	// --------------------------------------------------------------------
210
+
211
+	/**
212
+	 * Delete all existing cache files
213
+	 *
214
+	 * @return	void
215
+	 */
216
+	public function delete_all()
217
+	{
218
+		delete_files($this->db->cachedir, TRUE, TRUE);
219
+	}
220
+
221
+}

Datei-Diff unterdrückt, da er zu groß ist
+ 1985 - 0
system/database/DB_driver.php


Datei-Diff unterdrückt, da er zu groß ist
+ 1033 - 0
system/database/DB_forge.php


Datei-Diff unterdrückt, da er zu groß ist
+ 2808 - 0
system/database/DB_query_builder.php


+ 665 - 0
system/database/DB_result.php Datei anzeigen

@@ -0,0 +1,665 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Database Result Class
42
+ *
43
+ * This is the platform-independent result class.
44
+ * This class will not be called directly. Rather, the adapter
45
+ * class for the specific database will extend and instantiate it.
46
+ *
47
+ * @category	Database
48
+ * @author		EllisLab Dev Team
49
+ * @link		https://codeigniter.com/user_guide/database/
50
+ */
51
+class CI_DB_result {
52
+
53
+	/**
54
+	 * Connection ID
55
+	 *
56
+	 * @var	resource|object
57
+	 */
58
+	public $conn_id;
59
+
60
+	/**
61
+	 * Result ID
62
+	 *
63
+	 * @var	resource|object
64
+	 */
65
+	public $result_id;
66
+
67
+	/**
68
+	 * Result Array
69
+	 *
70
+	 * @var	array[]
71
+	 */
72
+	public $result_array			= array();
73
+
74
+	/**
75
+	 * Result Object
76
+	 *
77
+	 * @var	object[]
78
+	 */
79
+	public $result_object			= array();
80
+
81
+	/**
82
+	 * Custom Result Object
83
+	 *
84
+	 * @var	object[]
85
+	 */
86
+	public $custom_result_object		= array();
87
+
88
+	/**
89
+	 * Current Row index
90
+	 *
91
+	 * @var	int
92
+	 */
93
+	public $current_row			= 0;
94
+
95
+	/**
96
+	 * Number of rows
97
+	 *
98
+	 * @var	int
99
+	 */
100
+	public $num_rows;
101
+
102
+	/**
103
+	 * Row data
104
+	 *
105
+	 * @var	array
106
+	 */
107
+	public $row_data;
108
+
109
+	// --------------------------------------------------------------------
110
+
111
+	/**
112
+	 * Constructor
113
+	 *
114
+	 * @param	object	$driver_object
115
+	 * @return	void
116
+	 */
117
+	public function __construct(&$driver_object)
118
+	{
119
+		$this->conn_id = $driver_object->conn_id;
120
+		$this->result_id = $driver_object->result_id;
121
+	}
122
+
123
+	// --------------------------------------------------------------------
124
+
125
+	/**
126
+	 * Number of rows in the result set
127
+	 *
128
+	 * @return	int
129
+	 */
130
+	public function num_rows()
131
+	{
132
+		if (is_int($this->num_rows))
133
+		{
134
+			return $this->num_rows;
135
+		}
136
+		elseif (count($this->result_array) > 0)
137
+		{
138
+			return $this->num_rows = count($this->result_array);
139
+		}
140
+		elseif (count($this->result_object) > 0)
141
+		{
142
+			return $this->num_rows = count($this->result_object);
143
+		}
144
+
145
+		return $this->num_rows = count($this->result_array());
146
+	}
147
+
148
+	// --------------------------------------------------------------------
149
+
150
+	/**
151
+	 * Query result. Acts as a wrapper function for the following functions.
152
+	 *
153
+	 * @param	string	$type	'object', 'array' or a custom class name
154
+	 * @return	array
155
+	 */
156
+	public function result($type = 'object')
157
+	{
158
+		if ($type === 'array')
159
+		{
160
+			return $this->result_array();
161
+		}
162
+		elseif ($type === 'object')
163
+		{
164
+			return $this->result_object();
165
+		}
166
+
167
+		return $this->custom_result_object($type);
168
+	}
169
+
170
+	// --------------------------------------------------------------------
171
+
172
+	/**
173
+	 * Custom query result.
174
+	 *
175
+	 * @param	string	$class_name
176
+	 * @return	array
177
+	 */
178
+	public function custom_result_object($class_name)
179
+	{
180
+		if (isset($this->custom_result_object[$class_name]))
181
+		{
182
+			return $this->custom_result_object[$class_name];
183
+		}
184
+		elseif ( ! $this->result_id OR $this->num_rows === 0)
185
+		{
186
+			return array();
187
+		}
188
+
189
+		// Don't fetch the result set again if we already have it
190
+		$_data = NULL;
191
+		if (($c = count($this->result_array)) > 0)
192
+		{
193
+			$_data = 'result_array';
194
+		}
195
+		elseif (($c = count($this->result_object)) > 0)
196
+		{
197
+			$_data = 'result_object';
198
+		}
199
+
200
+		if ($_data !== NULL)
201
+		{
202
+			for ($i = 0; $i < $c; $i++)
203
+			{
204
+				$this->custom_result_object[$class_name][$i] = new $class_name();
205
+
206
+				foreach ($this->{$_data}[$i] as $key => $value)
207
+				{
208
+					$this->custom_result_object[$class_name][$i]->$key = $value;
209
+				}
210
+			}
211
+
212
+			return $this->custom_result_object[$class_name];
213
+		}
214
+
215
+		is_null($this->row_data) OR $this->data_seek(0);
216
+		$this->custom_result_object[$class_name] = array();
217
+
218
+		while ($row = $this->_fetch_object($class_name))
219
+		{
220
+			$this->custom_result_object[$class_name][] = $row;
221
+		}
222
+
223
+		return $this->custom_result_object[$class_name];
224
+	}
225
+
226
+	// --------------------------------------------------------------------
227
+
228
+	/**
229
+	 * Query result. "object" version.
230
+	 *
231
+	 * @return	array
232
+	 */
233
+	public function result_object()
234
+	{
235
+		if (count($this->result_object) > 0)
236
+		{
237
+			return $this->result_object;
238
+		}
239
+
240
+		// In the event that query caching is on, the result_id variable
241
+		// will not be a valid resource so we'll simply return an empty
242
+		// array.
243
+		if ( ! $this->result_id OR $this->num_rows === 0)
244
+		{
245
+			return array();
246
+		}
247
+
248
+		if (($c = count($this->result_array)) > 0)
249
+		{
250
+			for ($i = 0; $i < $c; $i++)
251
+			{
252
+				$this->result_object[$i] = (object) $this->result_array[$i];
253
+			}
254
+
255
+			return $this->result_object;
256
+		}
257
+
258
+		is_null($this->row_data) OR $this->data_seek(0);
259
+		while ($row = $this->_fetch_object())
260
+		{
261
+			$this->result_object[] = $row;
262
+		}
263
+
264
+		return $this->result_object;
265
+	}
266
+
267
+	// --------------------------------------------------------------------
268
+
269
+	/**
270
+	 * Query result. "array" version.
271
+	 *
272
+	 * @return	array
273
+	 */
274
+	public function result_array()
275
+	{
276
+		if (count($this->result_array) > 0)
277
+		{
278
+			return $this->result_array;
279
+		}
280
+
281
+		// In the event that query caching is on, the result_id variable
282
+		// will not be a valid resource so we'll simply return an empty
283
+		// array.
284
+		if ( ! $this->result_id OR $this->num_rows === 0)
285
+		{
286
+			return array();
287
+		}
288
+
289
+		if (($c = count($this->result_object)) > 0)
290
+		{
291
+			for ($i = 0; $i < $c; $i++)
292
+			{
293
+				$this->result_array[$i] = (array) $this->result_object[$i];
294
+			}
295
+
296
+			return $this->result_array;
297
+		}
298
+
299
+		is_null($this->row_data) OR $this->data_seek(0);
300
+		while ($row = $this->_fetch_assoc())
301
+		{
302
+			$this->result_array[] = $row;
303
+		}
304
+
305
+		return $this->result_array;
306
+	}
307
+
308
+	// --------------------------------------------------------------------
309
+
310
+	/**
311
+	 * Row
312
+	 *
313
+	 * A wrapper method.
314
+	 *
315
+	 * @param	mixed	$n
316
+	 * @param	string	$type	'object' or 'array'
317
+	 * @return	mixed
318
+	 */
319
+	public function row($n = 0, $type = 'object')
320
+	{
321
+		if ( ! is_numeric($n))
322
+		{
323
+			// We cache the row data for subsequent uses
324
+			is_array($this->row_data) OR $this->row_data = $this->row_array(0);
325
+
326
+			// array_key_exists() instead of isset() to allow for NULL values
327
+			if (empty($this->row_data) OR ! array_key_exists($n, $this->row_data))
328
+			{
329
+				return NULL;
330
+			}
331
+
332
+			return $this->row_data[$n];
333
+		}
334
+
335
+		if ($type === 'object') return $this->row_object($n);
336
+		elseif ($type === 'array') return $this->row_array($n);
337
+
338
+		return $this->custom_row_object($n, $type);
339
+	}
340
+
341
+	// --------------------------------------------------------------------
342
+
343
+	/**
344
+	 * Assigns an item into a particular column slot
345
+	 *
346
+	 * @param	mixed	$key
347
+	 * @param	mixed	$value
348
+	 * @return	void
349
+	 */
350
+	public function set_row($key, $value = NULL)
351
+	{
352
+		// We cache the row data for subsequent uses
353
+		if ( ! is_array($this->row_data))
354
+		{
355
+			$this->row_data = $this->row_array(0);
356
+		}
357
+
358
+		if (is_array($key))
359
+		{
360
+			foreach ($key as $k => $v)
361
+			{
362
+				$this->row_data[$k] = $v;
363
+			}
364
+			return;
365
+		}
366
+
367
+		if ($key !== '' && $value !== NULL)
368
+		{
369
+			$this->row_data[$key] = $value;
370
+		}
371
+	}
372
+
373
+	// --------------------------------------------------------------------
374
+
375
+	/**
376
+	 * Returns a single result row - custom object version
377
+	 *
378
+	 * @param	int	$n
379
+	 * @param	string	$type
380
+	 * @return	object
381
+	 */
382
+	public function custom_row_object($n, $type)
383
+	{
384
+		isset($this->custom_result_object[$type]) OR $this->custom_result_object[$type] = $this->custom_result_object($type);
385
+
386
+		if (count($this->custom_result_object[$type]) === 0)
387
+		{
388
+			return NULL;
389
+		}
390
+
391
+		if ($n !== $this->current_row && isset($this->custom_result_object[$type][$n]))
392
+		{
393
+			$this->current_row = $n;
394
+		}
395
+
396
+		return $this->custom_result_object[$type][$this->current_row];
397
+	}
398
+
399
+	// --------------------------------------------------------------------
400
+
401
+	/**
402
+	 * Returns a single result row - object version
403
+	 *
404
+	 * @param	int	$n
405
+	 * @return	object
406
+	 */
407
+	public function row_object($n = 0)
408
+	{
409
+		$result = $this->result_object();
410
+		if (count($result) === 0)
411
+		{
412
+			return NULL;
413
+		}
414
+
415
+		if ($n !== $this->current_row && isset($result[$n]))
416
+		{
417
+			$this->current_row = $n;
418
+		}
419
+
420
+		return $result[$this->current_row];
421
+	}
422
+
423
+	// --------------------------------------------------------------------
424
+
425
+	/**
426
+	 * Returns a single result row - array version
427
+	 *
428
+	 * @param	int	$n
429
+	 * @return	array
430
+	 */
431
+	public function row_array($n = 0)
432
+	{
433
+		$result = $this->result_array();
434
+		if (count($result) === 0)
435
+		{
436
+			return NULL;
437
+		}
438
+
439
+		if ($n !== $this->current_row && isset($result[$n]))
440
+		{
441
+			$this->current_row = $n;
442
+		}
443
+
444
+		return $result[$this->current_row];
445
+	}
446
+
447
+	// --------------------------------------------------------------------
448
+
449
+	/**
450
+	 * Returns the "first" row
451
+	 *
452
+	 * @param	string	$type
453
+	 * @return	mixed
454
+	 */
455
+	public function first_row($type = 'object')
456
+	{
457
+		$result = $this->result($type);
458
+		return (count($result) === 0) ? NULL : $result[0];
459
+	}
460
+
461
+	// --------------------------------------------------------------------
462
+
463
+	/**
464
+	 * Returns the "last" row
465
+	 *
466
+	 * @param	string	$type
467
+	 * @return	mixed
468
+	 */
469
+	public function last_row($type = 'object')
470
+	{
471
+		$result = $this->result($type);
472
+		return (count($result) === 0) ? NULL : $result[count($result) - 1];
473
+	}
474
+
475
+	// --------------------------------------------------------------------
476
+
477
+	/**
478
+	 * Returns the "next" row
479
+	 *
480
+	 * @param	string	$type
481
+	 * @return	mixed
482
+	 */
483
+	public function next_row($type = 'object')
484
+	{
485
+		$result = $this->result($type);
486
+		if (count($result) === 0)
487
+		{
488
+			return NULL;
489
+		}
490
+
491
+		return isset($result[$this->current_row + 1])
492
+			? $result[++$this->current_row]
493
+			: NULL;
494
+	}
495
+
496
+	// --------------------------------------------------------------------
497
+
498
+	/**
499
+	 * Returns the "previous" row
500
+	 *
501
+	 * @param	string	$type
502
+	 * @return	mixed
503
+	 */
504
+	public function previous_row($type = 'object')
505
+	{
506
+		$result = $this->result($type);
507
+		if (count($result) === 0)
508
+		{
509
+			return NULL;
510
+		}
511
+
512
+		if (isset($result[$this->current_row - 1]))
513
+		{
514
+			--$this->current_row;
515
+		}
516
+		return $result[$this->current_row];
517
+	}
518
+
519
+	// --------------------------------------------------------------------
520
+
521
+	/**
522
+	 * Returns an unbuffered row and move pointer to next row
523
+	 *
524
+	 * @param	string	$type	'array', 'object' or a custom class name
525
+	 * @return	mixed
526
+	 */
527
+	public function unbuffered_row($type = 'object')
528
+	{
529
+		if ($type === 'array')
530
+		{
531
+			return $this->_fetch_assoc();
532
+		}
533
+		elseif ($type === 'object')
534
+		{
535
+			return $this->_fetch_object();
536
+		}
537
+
538
+		return $this->_fetch_object($type);
539
+	}
540
+
541
+	// --------------------------------------------------------------------
542
+
543
+	/**
544
+	 * The following methods are normally overloaded by the identically named
545
+	 * methods in the platform-specific driver -- except when query caching
546
+	 * is used. When caching is enabled we do not load the other driver.
547
+	 * These functions are primarily here to prevent undefined function errors
548
+	 * when a cached result object is in use. They are not otherwise fully
549
+	 * operational due to the unavailability of the database resource IDs with
550
+	 * cached results.
551
+	 */
552
+
553
+	// --------------------------------------------------------------------
554
+
555
+	/**
556
+	 * Number of fields in the result set
557
+	 *
558
+	 * Overridden by driver result classes.
559
+	 *
560
+	 * @return	int
561
+	 */
562
+	public function num_fields()
563
+	{
564
+		return 0;
565
+	}
566
+
567
+	// --------------------------------------------------------------------
568
+
569
+	/**
570
+	 * Fetch Field Names
571
+	 *
572
+	 * Generates an array of column names.
573
+	 *
574
+	 * Overridden by driver result classes.
575
+	 *
576
+	 * @return	array
577
+	 */
578
+	public function list_fields()
579
+	{
580
+		return array();
581
+	}
582
+
583
+	// --------------------------------------------------------------------
584
+
585
+	/**
586
+	 * Field data
587
+	 *
588
+	 * Generates an array of objects containing field meta-data.
589
+	 *
590
+	 * Overridden by driver result classes.
591
+	 *
592
+	 * @return	array
593
+	 */
594
+	public function field_data()
595
+	{
596
+		return array();
597
+	}
598
+
599
+	// --------------------------------------------------------------------
600
+
601
+	/**
602
+	 * Free the result
603
+	 *
604
+	 * Overridden by driver result classes.
605
+	 *
606
+	 * @return	void
607
+	 */
608
+	public function free_result()
609
+	{
610
+		$this->result_id = FALSE;
611
+	}
612
+
613
+	// --------------------------------------------------------------------
614
+
615
+	/**
616
+	 * Data Seek
617
+	 *
618
+	 * Moves the internal pointer to the desired offset. We call
619
+	 * this internally before fetching results to make sure the
620
+	 * result set starts at zero.
621
+	 *
622
+	 * Overridden by driver result classes.
623
+	 *
624
+	 * @param	int	$n
625
+	 * @return	bool
626
+	 */
627
+	public function data_seek($n = 0)
628
+	{
629
+		return FALSE;
630
+	}
631
+
632
+	// --------------------------------------------------------------------
633
+
634
+	/**
635
+	 * Result - associative array
636
+	 *
637
+	 * Returns the result set as an array.
638
+	 *
639
+	 * Overridden by driver result classes.
640
+	 *
641
+	 * @return	array
642
+	 */
643
+	protected function _fetch_assoc()
644
+	{
645
+		return array();
646
+	}
647
+
648
+	// --------------------------------------------------------------------
649
+
650
+	/**
651
+	 * Result - object
652
+	 *
653
+	 * Returns the result set as an object.
654
+	 *
655
+	 * Overridden by driver result classes.
656
+	 *
657
+	 * @param	string	$class_name
658
+	 * @return	object
659
+	 */
660
+	protected function _fetch_object($class_name = 'stdClass')
661
+	{
662
+		return new $class_name();
663
+	}
664
+
665
+}

+ 424 - 0
system/database/DB_utility.php Datei anzeigen

@@ -0,0 +1,424 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Database Utility Class
42
+ *
43
+ * @category	Database
44
+ * @author		EllisLab Dev Team
45
+ * @link		https://codeigniter.com/user_guide/database/
46
+ */
47
+abstract class CI_DB_utility {
48
+
49
+	/**
50
+	 * Database object
51
+	 *
52
+	 * @var	object
53
+	 */
54
+	protected $db;
55
+
56
+	// --------------------------------------------------------------------
57
+
58
+	/**
59
+	 * List databases statement
60
+	 *
61
+	 * @var	string
62
+	 */
63
+	protected $_list_databases		= FALSE;
64
+
65
+	/**
66
+	 * OPTIMIZE TABLE statement
67
+	 *
68
+	 * @var	string
69
+	 */
70
+	protected $_optimize_table	= FALSE;
71
+
72
+	/**
73
+	 * REPAIR TABLE statement
74
+	 *
75
+	 * @var	string
76
+	 */
77
+	protected $_repair_table	= FALSE;
78
+
79
+	// --------------------------------------------------------------------
80
+
81
+	/**
82
+	 * Class constructor
83
+	 *
84
+	 * @param	object	&$db	Database object
85
+	 * @return	void
86
+	 */
87
+	public function __construct(&$db)
88
+	{
89
+		$this->db =& $db;
90
+		log_message('info', 'Database Utility Class Initialized');
91
+	}
92
+
93
+	// --------------------------------------------------------------------
94
+
95
+	/**
96
+	 * List databases
97
+	 *
98
+	 * @return	array
99
+	 */
100
+	public function list_databases()
101
+	{
102
+		// Is there a cached result?
103
+		if (isset($this->db->data_cache['db_names']))
104
+		{
105
+			return $this->db->data_cache['db_names'];
106
+		}
107
+		elseif ($this->_list_databases === FALSE)
108
+		{
109
+			return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
110
+		}
111
+
112
+		$this->db->data_cache['db_names'] = array();
113
+
114
+		$query = $this->db->query($this->_list_databases);
115
+		if ($query === FALSE)
116
+		{
117
+			return $this->db->data_cache['db_names'];
118
+		}
119
+
120
+		for ($i = 0, $query = $query->result_array(), $c = count($query); $i < $c; $i++)
121
+		{
122
+			$this->db->data_cache['db_names'][] = current($query[$i]);
123
+		}
124
+
125
+		return $this->db->data_cache['db_names'];
126
+	}
127
+
128
+	// --------------------------------------------------------------------
129
+
130
+	/**
131
+	 * Determine if a particular database exists
132
+	 *
133
+	 * @param	string	$database_name
134
+	 * @return	bool
135
+	 */
136
+	public function database_exists($database_name)
137
+	{
138
+		return in_array($database_name, $this->list_databases());
139
+	}
140
+
141
+	// --------------------------------------------------------------------
142
+
143
+	/**
144
+	 * Optimize Table
145
+	 *
146
+	 * @param	string	$table_name
147
+	 * @return	mixed
148
+	 */
149
+	public function optimize_table($table_name)
150
+	{
151
+		if ($this->_optimize_table === FALSE)
152
+		{
153
+			return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
154
+		}
155
+
156
+		$query = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name)));
157
+		if ($query !== FALSE)
158
+		{
159
+			$query = $query->result_array();
160
+			return current($query);
161
+		}
162
+
163
+		return FALSE;
164
+	}
165
+
166
+	// --------------------------------------------------------------------
167
+
168
+	/**
169
+	 * Optimize Database
170
+	 *
171
+	 * @return	mixed
172
+	 */
173
+	public function optimize_database()
174
+	{
175
+		if ($this->_optimize_table === FALSE)
176
+		{
177
+			return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
178
+		}
179
+
180
+		$result = array();
181
+		foreach ($this->db->list_tables() as $table_name)
182
+		{
183
+			$res = $this->db->query(sprintf($this->_optimize_table, $this->db->escape_identifiers($table_name)));
184
+			if (is_bool($res))
185
+			{
186
+				return $res;
187
+			}
188
+
189
+			// Build the result array...
190
+			$res = $res->result_array();
191
+			$res = current($res);
192
+			$key = str_replace($this->db->database.'.', '', current($res));
193
+			$keys = array_keys($res);
194
+			unset($res[$keys[0]]);
195
+
196
+			$result[$key] = $res;
197
+		}
198
+
199
+		return $result;
200
+	}
201
+
202
+	// --------------------------------------------------------------------
203
+
204
+	/**
205
+	 * Repair Table
206
+	 *
207
+	 * @param	string	$table_name
208
+	 * @return	mixed
209
+	 */
210
+	public function repair_table($table_name)
211
+	{
212
+		if ($this->_repair_table === FALSE)
213
+		{
214
+			return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
215
+		}
216
+
217
+		$query = $this->db->query(sprintf($this->_repair_table, $this->db->escape_identifiers($table_name)));
218
+		if (is_bool($query))
219
+		{
220
+			return $query;
221
+		}
222
+
223
+		$query = $query->result_array();
224
+		return current($query);
225
+	}
226
+
227
+	// --------------------------------------------------------------------
228
+
229
+	/**
230
+	 * Generate CSV from a query result object
231
+	 *
232
+	 * @param	object	$query		Query result object
233
+	 * @param	string	$delim		Delimiter (default: ,)
234
+	 * @param	string	$newline	Newline character (default: \n)
235
+	 * @param	string	$enclosure	Enclosure (default: ")
236
+	 * @return	string
237
+	 */
238
+	public function csv_from_result($query, $delim = ',', $newline = "\n", $enclosure = '"')
239
+	{
240
+		if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
241
+		{
242
+			show_error('You must submit a valid result object');
243
+		}
244
+
245
+		$out = '';
246
+		// First generate the headings from the table column names
247
+		foreach ($query->list_fields() as $name)
248
+		{
249
+			$out .= $enclosure.str_replace($enclosure, $enclosure.$enclosure, $name).$enclosure.$delim;
250
+		}
251
+
252
+		$out = substr($out, 0, -strlen($delim)).$newline;
253
+
254
+		// Next blast through the result array and build out the rows
255
+		while ($row = $query->unbuffered_row('array'))
256
+		{
257
+			$line = array();
258
+			foreach ($row as $item)
259
+			{
260
+				$line[] = $enclosure.str_replace($enclosure, $enclosure.$enclosure, $item).$enclosure;
261
+			}
262
+			$out .= implode($delim, $line).$newline;
263
+		}
264
+
265
+		return $out;
266
+	}
267
+
268
+	// --------------------------------------------------------------------
269
+
270
+	/**
271
+	 * Generate XML data from a query result object
272
+	 *
273
+	 * @param	object	$query	Query result object
274
+	 * @param	array	$params	Any preferences
275
+	 * @return	string
276
+	 */
277
+	public function xml_from_result($query, $params = array())
278
+	{
279
+		if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
280
+		{
281
+			show_error('You must submit a valid result object');
282
+		}
283
+
284
+		// Set our default values
285
+		foreach (array('root' => 'root', 'element' => 'element', 'newline' => "\n", 'tab' => "\t") as $key => $val)
286
+		{
287
+			if ( ! isset($params[$key]))
288
+			{
289
+				$params[$key] = $val;
290
+			}
291
+		}
292
+
293
+		// Create variables for convenience
294
+		extract($params);
295
+
296
+		// Load the xml helper
297
+		get_instance()->load->helper('xml');
298
+
299
+		// Generate the result
300
+		$xml = '<'.$root.'>'.$newline;
301
+		while ($row = $query->unbuffered_row())
302
+		{
303
+			$xml .= $tab.'<'.$element.'>'.$newline;
304
+			foreach ($row as $key => $val)
305
+			{
306
+				$xml .= $tab.$tab.'<'.$key.'>'.xml_convert($val).'</'.$key.'>'.$newline;
307
+			}
308
+			$xml .= $tab.'</'.$element.'>'.$newline;
309
+		}
310
+
311
+		return $xml.'</'.$root.'>'.$newline;
312
+	}
313
+
314
+	// --------------------------------------------------------------------
315
+
316
+	/**
317
+	 * Database Backup
318
+	 *
319
+	 * @param	array	$params
320
+	 * @return	string
321
+	 */
322
+	public function backup($params = array())
323
+	{
324
+		// If the parameters have not been submitted as an
325
+		// array then we know that it is simply the table
326
+		// name, which is a valid short cut.
327
+		if (is_string($params))
328
+		{
329
+			$params = array('tables' => $params);
330
+		}
331
+
332
+		// Set up our default preferences
333
+		$prefs = array(
334
+			'tables'		=> array(),
335
+			'ignore'		=> array(),
336
+			'filename'		=> '',
337
+			'format'		=> 'gzip', // gzip, zip, txt
338
+			'add_drop'		=> TRUE,
339
+			'add_insert'		=> TRUE,
340
+			'newline'		=> "\n",
341
+			'foreign_key_checks'	=> TRUE
342
+		);
343
+
344
+		// Did the user submit any preferences? If so set them....
345
+		if (count($params) > 0)
346
+		{
347
+			foreach ($prefs as $key => $val)
348
+			{
349
+				if (isset($params[$key]))
350
+				{
351
+					$prefs[$key] = $params[$key];
352
+				}
353
+			}
354
+		}
355
+
356
+		// Are we backing up a complete database or individual tables?
357
+		// If no table names were submitted we'll fetch the entire table list
358
+		if (count($prefs['tables']) === 0)
359
+		{
360
+			$prefs['tables'] = $this->db->list_tables();
361
+		}
362
+
363
+		// Validate the format
364
+		if ( ! in_array($prefs['format'], array('gzip', 'zip', 'txt'), TRUE))
365
+		{
366
+			$prefs['format'] = 'txt';
367
+		}
368
+
369
+		// Is the encoder supported? If not, we'll either issue an
370
+		// error or use plain text depending on the debug settings
371
+		if (($prefs['format'] === 'gzip' && ! function_exists('gzencode'))
372
+			OR ($prefs['format'] === 'zip' && ! function_exists('gzcompress')))
373
+		{
374
+			if ($this->db->db_debug)
375
+			{
376
+				return $this->db->display_error('db_unsupported_compression');
377
+			}
378
+
379
+			$prefs['format'] = 'txt';
380
+		}
381
+
382
+		// Was a Zip file requested?
383
+		if ($prefs['format'] === 'zip')
384
+		{
385
+			// Set the filename if not provided (only needed with Zip files)
386
+			if ($prefs['filename'] === '')
387
+			{
388
+				$prefs['filename'] = (count($prefs['tables']) === 1 ? $prefs['tables'] : $this->db->database)
389
+							.date('Y-m-d_H-i', time()).'.sql';
390
+			}
391
+			else
392
+			{
393
+				// If they included the .zip file extension we'll remove it
394
+				if (preg_match('|.+?\.zip$|', $prefs['filename']))
395
+				{
396
+					$prefs['filename'] = str_replace('.zip', '', $prefs['filename']);
397
+				}
398
+
399
+				// Tack on the ".sql" file extension if needed
400
+				if ( ! preg_match('|.+?\.sql$|', $prefs['filename']))
401
+				{
402
+					$prefs['filename'] .= '.sql';
403
+				}
404
+			}
405
+
406
+			// Load the Zip class and output it
407
+			$CI =& get_instance();
408
+			$CI->load->library('zip');
409
+			$CI->zip->add_data($prefs['filename'], $this->_backup($prefs));
410
+			return $CI->zip->get_zip();
411
+		}
412
+		elseif ($prefs['format'] === 'txt') // Was a text file requested?
413
+		{
414
+			return $this->_backup($prefs);
415
+		}
416
+		elseif ($prefs['format'] === 'gzip') // Was a Gzip file requested?
417
+		{
418
+			return gzencode($this->_backup($prefs));
419
+		}
420
+
421
+		return;
422
+	}
423
+
424
+}

+ 405 - 0
system/database/drivers/cubrid/cubrid_driver.php Datei anzeigen

@@ -0,0 +1,405 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 2.1.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * CUBRID Database Adapter Class
42
+ *
43
+ * Note: _DB is an extender class that the app controller
44
+ * creates dynamically based on whether the query builder
45
+ * class is being used or not.
46
+ *
47
+ * @package		CodeIgniter
48
+ * @subpackage	Drivers
49
+ * @category	Database
50
+ * @author		Esen Sagynov
51
+ * @link		https://codeigniter.com/user_guide/database/
52
+ */
53
+class CI_DB_cubrid_driver extends CI_DB {
54
+
55
+	/**
56
+	 * Database driver
57
+	 *
58
+	 * @var	string
59
+	 */
60
+	public $dbdriver = 'cubrid';
61
+
62
+	/**
63
+	 * Auto-commit flag
64
+	 *
65
+	 * @var	bool
66
+	 */
67
+	public $auto_commit = TRUE;
68
+
69
+	// --------------------------------------------------------------------
70
+
71
+	/**
72
+	 * Identifier escape character
73
+	 *
74
+	 * @var	string
75
+	 */
76
+	protected $_escape_char = '`';
77
+
78
+	/**
79
+	 * ORDER BY random keyword
80
+	 *
81
+	 * @var	array
82
+	 */
83
+	protected $_random_keyword = array('RANDOM()', 'RANDOM(%d)');
84
+
85
+	// --------------------------------------------------------------------
86
+
87
+	/**
88
+	 * Class constructor
89
+	 *
90
+	 * @param	array	$params
91
+	 * @return	void
92
+	 */
93
+	public function __construct($params)
94
+	{
95
+		parent::__construct($params);
96
+
97
+		if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:[^:]*:[^:]*:(\?.+)?$/', $this->dsn, $matches))
98
+		{
99
+			if (stripos($matches[2], 'autocommit=off') !== FALSE)
100
+			{
101
+				$this->auto_commit = FALSE;
102
+			}
103
+		}
104
+		else
105
+		{
106
+			// If no port is defined by the user, use the default value
107
+			empty($this->port) OR $this->port = 33000;
108
+		}
109
+	}
110
+
111
+	// --------------------------------------------------------------------
112
+
113
+	/**
114
+	 * Non-persistent database connection
115
+	 *
116
+	 * @param	bool	$persistent
117
+	 * @return	resource
118
+	 */
119
+	public function db_connect($persistent = FALSE)
120
+	{
121
+		if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:([^:]*):([^:]*):(\?.+)?$/', $this->dsn, $matches))
122
+		{
123
+			$func = ($persistent !== TRUE) ? 'cubrid_connect_with_url' : 'cubrid_pconnect_with_url';
124
+			return ($matches[2] === '' && $matches[3] === '' && $this->username !== '' && $this->password !== '')
125
+				? $func($this->dsn, $this->username, $this->password)
126
+				: $func($this->dsn);
127
+		}
128
+
129
+		$func = ($persistent !== TRUE) ? 'cubrid_connect' : 'cubrid_pconnect';
130
+		return ($this->username !== '')
131
+			? $func($this->hostname, $this->port, $this->database, $this->username, $this->password)
132
+			: $func($this->hostname, $this->port, $this->database);
133
+	}
134
+
135
+	// --------------------------------------------------------------------
136
+
137
+	/**
138
+	 * Reconnect
139
+	 *
140
+	 * Keep / reestablish the db connection if no queries have been
141
+	 * sent for a length of time exceeding the server's idle timeout
142
+	 *
143
+	 * @return	void
144
+	 */
145
+	public function reconnect()
146
+	{
147
+		if (cubrid_ping($this->conn_id) === FALSE)
148
+		{
149
+			$this->conn_id = FALSE;
150
+		}
151
+	}
152
+
153
+	// --------------------------------------------------------------------
154
+
155
+	/**
156
+	 * Database version number
157
+	 *
158
+	 * @return	string
159
+	 */
160
+	public function version()
161
+	{
162
+		if (isset($this->data_cache['version']))
163
+		{
164
+			return $this->data_cache['version'];
165
+		}
166
+
167
+		return ( ! $this->conn_id OR ($version = cubrid_get_server_info($this->conn_id)) === FALSE)
168
+			? FALSE
169
+			: $this->data_cache['version'] = $version;
170
+	}
171
+
172
+	// --------------------------------------------------------------------
173
+
174
+	/**
175
+	 * Execute the query
176
+	 *
177
+	 * @param	string	$sql	an SQL query
178
+	 * @return	resource
179
+	 */
180
+	protected function _execute($sql)
181
+	{
182
+		return cubrid_query($sql, $this->conn_id);
183
+	}
184
+
185
+	// --------------------------------------------------------------------
186
+
187
+	/**
188
+	 * Begin Transaction
189
+	 *
190
+	 * @return	bool
191
+	 */
192
+	protected function _trans_begin()
193
+	{
194
+		if (($autocommit = cubrid_get_autocommit($this->conn_id)) === NULL)
195
+		{
196
+			return FALSE;
197
+		}
198
+		elseif ($autocommit === TRUE)
199
+		{
200
+			return cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_FALSE);
201
+		}
202
+
203
+		return TRUE;
204
+	}
205
+
206
+	// --------------------------------------------------------------------
207
+
208
+	/**
209
+	 * Commit Transaction
210
+	 *
211
+	 * @return	bool
212
+	 */
213
+	protected function _trans_commit()
214
+	{
215
+		if ( ! cubrid_commit($this->conn_id))
216
+		{
217
+			return FALSE;
218
+		}
219
+
220
+		if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
221
+		{
222
+			return cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
223
+		}
224
+
225
+		return TRUE;
226
+	}
227
+
228
+	// --------------------------------------------------------------------
229
+
230
+	/**
231
+	 * Rollback Transaction
232
+	 *
233
+	 * @return	bool
234
+	 */
235
+	protected function _trans_rollback()
236
+	{
237
+		if ( ! cubrid_rollback($this->conn_id))
238
+		{
239
+			return FALSE;
240
+		}
241
+
242
+		if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
243
+		{
244
+			cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
245
+		}
246
+
247
+		return TRUE;
248
+	}
249
+
250
+	// --------------------------------------------------------------------
251
+
252
+	/**
253
+	 * Platform-dependent string escape
254
+	 *
255
+	 * @param	string
256
+	 * @return	string
257
+	 */
258
+	protected function _escape_str($str)
259
+	{
260
+		return cubrid_real_escape_string($str, $this->conn_id);
261
+	}
262
+
263
+	// --------------------------------------------------------------------
264
+
265
+	/**
266
+	 * Affected Rows
267
+	 *
268
+	 * @return	int
269
+	 */
270
+	public function affected_rows()
271
+	{
272
+		return cubrid_affected_rows();
273
+	}
274
+
275
+	// --------------------------------------------------------------------
276
+
277
+	/**
278
+	 * Insert ID
279
+	 *
280
+	 * @return	int
281
+	 */
282
+	public function insert_id()
283
+	{
284
+		return cubrid_insert_id($this->conn_id);
285
+	}
286
+
287
+	// --------------------------------------------------------------------
288
+
289
+	/**
290
+	 * List table query
291
+	 *
292
+	 * Generates a platform-specific query string so that the table names can be fetched
293
+	 *
294
+	 * @param	bool	$prefix_limit
295
+	 * @return	string
296
+	 */
297
+	protected function _list_tables($prefix_limit = FALSE)
298
+	{
299
+		$sql = 'SHOW TABLES';
300
+
301
+		if ($prefix_limit !== FALSE && $this->dbprefix !== '')
302
+		{
303
+			return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'";
304
+		}
305
+
306
+		return $sql;
307
+	}
308
+
309
+	// --------------------------------------------------------------------
310
+
311
+	/**
312
+	 * Show column query
313
+	 *
314
+	 * Generates a platform-specific query string so that the column names can be fetched
315
+	 *
316
+	 * @param	string	$table
317
+	 * @return	string
318
+	 */
319
+	protected function _list_columns($table = '')
320
+	{
321
+		return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE);
322
+	}
323
+
324
+	// --------------------------------------------------------------------
325
+
326
+	/**
327
+	 * Returns an object with field data
328
+	 *
329
+	 * @param	string	$table
330
+	 * @return	array
331
+	 */
332
+	public function field_data($table)
333
+	{
334
+		if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
335
+		{
336
+			return FALSE;
337
+		}
338
+		$query = $query->result_object();
339
+
340
+		$retval = array();
341
+		for ($i = 0, $c = count($query); $i < $c; $i++)
342
+		{
343
+			$retval[$i]			= new stdClass();
344
+			$retval[$i]->name		= $query[$i]->Field;
345
+
346
+			sscanf($query[$i]->Type, '%[a-z](%d)',
347
+				$retval[$i]->type,
348
+				$retval[$i]->max_length
349
+			);
350
+
351
+			$retval[$i]->default		= $query[$i]->Default;
352
+			$retval[$i]->primary_key	= (int) ($query[$i]->Key === 'PRI');
353
+		}
354
+
355
+		return $retval;
356
+	}
357
+
358
+	// --------------------------------------------------------------------
359
+
360
+	/**
361
+	 * Error
362
+	 *
363
+	 * Returns an array containing code and message of the last
364
+	 * database error that has occurred.
365
+	 *
366
+	 * @return	array
367
+	 */
368
+	public function error()
369
+	{
370
+		return array('code' => cubrid_errno($this->conn_id), 'message' => cubrid_error($this->conn_id));
371
+	}
372
+
373
+	// --------------------------------------------------------------------
374
+
375
+	/**
376
+	 * FROM tables
377
+	 *
378
+	 * Groups tables in FROM clauses if needed, so there is no confusion
379
+	 * about operator precedence.
380
+	 *
381
+	 * @return	string
382
+	 */
383
+	protected function _from_tables()
384
+	{
385
+		if ( ! empty($this->qb_join) && count($this->qb_from) > 1)
386
+		{
387
+			return '('.implode(', ', $this->qb_from).')';
388
+		}
389
+
390
+		return implode(', ', $this->qb_from);
391
+	}
392
+
393
+	// --------------------------------------------------------------------
394
+
395
+	/**
396
+	 * Close DB Connection
397
+	 *
398
+	 * @return	void
399
+	 */
400
+	protected function _close()
401
+	{
402
+		cubrid_close($this->conn_id);
403
+	}
404
+
405
+}

+ 230 - 0
system/database/drivers/cubrid/cubrid_forge.php Datei anzeigen

@@ -0,0 +1,230 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 2.1.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * CUBRID Forge Class
42
+ *
43
+ * @category	Database
44
+ * @author		Esen Sagynov
45
+ * @link		https://codeigniter.com/user_guide/database/
46
+ */
47
+class CI_DB_cubrid_forge extends CI_DB_forge {
48
+
49
+	/**
50
+	 * CREATE DATABASE statement
51
+	 *
52
+	 * @var	string
53
+	 */
54
+	protected $_create_database	= FALSE;
55
+
56
+	/**
57
+	 * CREATE TABLE keys flag
58
+	 *
59
+	 * Whether table keys are created from within the
60
+	 * CREATE TABLE statement.
61
+	 *
62
+	 * @var	bool
63
+	 */
64
+	protected $_create_table_keys	= TRUE;
65
+
66
+	/**
67
+	 * DROP DATABASE statement
68
+	 *
69
+	 * @var	string
70
+	 */
71
+	protected $_drop_database	= FALSE;
72
+
73
+	/**
74
+	 * CREATE TABLE IF statement
75
+	 *
76
+	 * @var	string
77
+	 */
78
+	protected $_create_table_if	= FALSE;
79
+
80
+	/**
81
+	 * UNSIGNED support
82
+	 *
83
+	 * @var	array
84
+	 */
85
+	protected $_unsigned		= array(
86
+		'SHORT'		=> 'INTEGER',
87
+		'SMALLINT'	=> 'INTEGER',
88
+		'INT'		=> 'BIGINT',
89
+		'INTEGER'	=> 'BIGINT',
90
+		'BIGINT'	=> 'NUMERIC',
91
+		'FLOAT'		=> 'DOUBLE',
92
+		'REAL'		=> 'DOUBLE'
93
+	);
94
+
95
+	// --------------------------------------------------------------------
96
+
97
+	/**
98
+	 * ALTER TABLE
99
+	 *
100
+	 * @param	string	$alter_type	ALTER type
101
+	 * @param	string	$table		Table name
102
+	 * @param	mixed	$field		Column definition
103
+	 * @return	string|string[]
104
+	 */
105
+	protected function _alter_table($alter_type, $table, $field)
106
+	{
107
+		if (in_array($alter_type, array('DROP', 'ADD'), TRUE))
108
+		{
109
+			return parent::_alter_table($alter_type, $table, $field);
110
+		}
111
+
112
+		$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table);
113
+		$sqls = array();
114
+		for ($i = 0, $c = count($field); $i < $c; $i++)
115
+		{
116
+			if ($field[$i]['_literal'] !== FALSE)
117
+			{
118
+				$sqls[] = $sql.' CHANGE '.$field[$i]['_literal'];
119
+			}
120
+			else
121
+			{
122
+				$alter_type = empty($field[$i]['new_name']) ? ' MODIFY ' : ' CHANGE ';
123
+				$sqls[] = $sql.$alter_type.$this->_process_column($field[$i]);
124
+			}
125
+		}
126
+
127
+		return $sqls;
128
+	}
129
+
130
+	// --------------------------------------------------------------------
131
+
132
+	/**
133
+	 * Process column
134
+	 *
135
+	 * @param	array	$field
136
+	 * @return	string
137
+	 */
138
+	protected function _process_column($field)
139
+	{
140
+		$extra_clause = isset($field['after'])
141
+			? ' AFTER '.$this->db->escape_identifiers($field['after']) : '';
142
+
143
+		if (empty($extra_clause) && isset($field['first']) && $field['first'] === TRUE)
144
+		{
145
+			$extra_clause = ' FIRST';
146
+		}
147
+
148
+		return $this->db->escape_identifiers($field['name'])
149
+			.(empty($field['new_name']) ? '' : ' '.$this->db->escape_identifiers($field['new_name']))
150
+			.' '.$field['type'].$field['length']
151
+			.$field['unsigned']
152
+			.$field['null']
153
+			.$field['default']
154
+			.$field['auto_increment']
155
+			.$field['unique']
156
+			.$extra_clause;
157
+	}
158
+
159
+	// --------------------------------------------------------------------
160
+
161
+	/**
162
+	 * Field attribute TYPE
163
+	 *
164
+	 * Performs a data type mapping between different databases.
165
+	 *
166
+	 * @param	array	&$attributes
167
+	 * @return	void
168
+	 */
169
+	protected function _attr_type(&$attributes)
170
+	{
171
+		switch (strtoupper($attributes['TYPE']))
172
+		{
173
+			case 'TINYINT':
174
+				$attributes['TYPE'] = 'SMALLINT';
175
+				$attributes['UNSIGNED'] = FALSE;
176
+				return;
177
+			case 'MEDIUMINT':
178
+				$attributes['TYPE'] = 'INTEGER';
179
+				$attributes['UNSIGNED'] = FALSE;
180
+				return;
181
+			case 'LONGTEXT':
182
+				$attributes['TYPE'] = 'STRING';
183
+				return;
184
+			default: return;
185
+		}
186
+	}
187
+
188
+	// --------------------------------------------------------------------
189
+
190
+	/**
191
+	 * Process indexes
192
+	 *
193
+	 * @param	string	$table	(ignored)
194
+	 * @return	string
195
+	 */
196
+	protected function _process_indexes($table)
197
+	{
198
+		$sql = '';
199
+
200
+		for ($i = 0, $c = count($this->keys); $i < $c; $i++)
201
+		{
202
+			if (is_array($this->keys[$i]))
203
+			{
204
+				for ($i2 = 0, $c2 = count($this->keys[$i]); $i2 < $c2; $i2++)
205
+				{
206
+					if ( ! isset($this->fields[$this->keys[$i][$i2]]))
207
+					{
208
+						unset($this->keys[$i][$i2]);
209
+						continue;
210
+					}
211
+				}
212
+			}
213
+			elseif ( ! isset($this->fields[$this->keys[$i]]))
214
+			{
215
+				unset($this->keys[$i]);
216
+				continue;
217
+			}
218
+
219
+			is_array($this->keys[$i]) OR $this->keys[$i] = array($this->keys[$i]);
220
+
221
+			$sql .= ",\n\tKEY ".$this->db->escape_identifiers(implode('_', $this->keys[$i]))
222
+				.' ('.implode(', ', $this->db->escape_identifiers($this->keys[$i])).')';
223
+		}
224
+
225
+		$this->keys = array();
226
+
227
+		return $sql;
228
+	}
229
+
230
+}

+ 177 - 0
system/database/drivers/cubrid/cubrid_result.php Datei anzeigen

@@ -0,0 +1,177 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 2.1.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * CUBRID Result Class
42
+ *
43
+ * This class extends the parent result class: CI_DB_result
44
+ *
45
+ * @category	Database
46
+ * @author		Esen Sagynov
47
+ * @link		https://codeigniter.com/user_guide/database/
48
+ */
49
+class CI_DB_cubrid_result extends CI_DB_result {
50
+
51
+	/**
52
+	 * Number of rows in the result set
53
+	 *
54
+	 * @return	int
55
+	 */
56
+	public function num_rows()
57
+	{
58
+		return is_int($this->num_rows)
59
+			? $this->num_rows
60
+			: $this->num_rows = cubrid_num_rows($this->result_id);
61
+	}
62
+
63
+	// --------------------------------------------------------------------
64
+
65
+	/**
66
+	 * Number of fields in the result set
67
+	 *
68
+	 * @return	int
69
+	 */
70
+	public function num_fields()
71
+	{
72
+		return cubrid_num_fields($this->result_id);
73
+	}
74
+
75
+	// --------------------------------------------------------------------
76
+
77
+	/**
78
+	 * Fetch Field Names
79
+	 *
80
+	 * Generates an array of column names
81
+	 *
82
+	 * @return	array
83
+	 */
84
+	public function list_fields()
85
+	{
86
+		return cubrid_column_names($this->result_id);
87
+	}
88
+
89
+	// --------------------------------------------------------------------
90
+
91
+	/**
92
+	 * Field data
93
+	 *
94
+	 * Generates an array of objects containing field meta-data
95
+	 *
96
+	 * @return	array
97
+	 */
98
+	public function field_data()
99
+	{
100
+		$retval = array();
101
+
102
+		for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
103
+		{
104
+			$retval[$i]			= new stdClass();
105
+			$retval[$i]->name		= cubrid_field_name($this->result_id, $i);
106
+			$retval[$i]->type		= cubrid_field_type($this->result_id, $i);
107
+			$retval[$i]->max_length		= cubrid_field_len($this->result_id, $i);
108
+			$retval[$i]->primary_key	= (int) (strpos(cubrid_field_flags($this->result_id, $i), 'primary_key') !== FALSE);
109
+		}
110
+
111
+		return $retval;
112
+	}
113
+
114
+	// --------------------------------------------------------------------
115
+
116
+	/**
117
+	 * Free the result
118
+	 *
119
+	 * @return	void
120
+	 */
121
+	public function free_result()
122
+	{
123
+		if (is_resource($this->result_id) OR
124
+			(get_resource_type($this->result_id) === 'Unknown' && preg_match('/Resource id #/', strval($this->result_id))))
125
+		{
126
+			cubrid_close_request($this->result_id);
127
+			$this->result_id = FALSE;
128
+		}
129
+	}
130
+
131
+	// --------------------------------------------------------------------
132
+
133
+	/**
134
+	 * Data Seek
135
+	 *
136
+	 * Moves the internal pointer to the desired offset. We call
137
+	 * this internally before fetching results to make sure the
138
+	 * result set starts at zero.
139
+	 *
140
+	 * @param	int	$n
141
+	 * @return	bool
142
+	 */
143
+	public function data_seek($n = 0)
144
+	{
145
+		return cubrid_data_seek($this->result_id, $n);
146
+	}
147
+
148
+	// --------------------------------------------------------------------
149
+
150
+	/**
151
+	 * Result - associative array
152
+	 *
153
+	 * Returns the result set as an array
154
+	 *
155
+	 * @return	array
156
+	 */
157
+	protected function _fetch_assoc()
158
+	{
159
+		return cubrid_fetch_assoc($this->result_id);
160
+	}
161
+
162
+	// --------------------------------------------------------------------
163
+
164
+	/**
165
+	 * Result - object
166
+	 *
167
+	 * Returns the result set as an object
168
+	 *
169
+	 * @param	string	$class_name
170
+	 * @return	object
171
+	 */
172
+	protected function _fetch_object($class_name = 'stdClass')
173
+	{
174
+		return cubrid_fetch_object($this->result_id, $class_name);
175
+	}
176
+
177
+}

+ 79 - 0
system/database/drivers/cubrid/cubrid_utility.php Datei anzeigen

@@ -0,0 +1,79 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 2.1.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * CUBRID Utility Class
42
+ *
43
+ * @category	Database
44
+ * @author		Esen Sagynov
45
+ * @link		https://codeigniter.com/user_guide/database/
46
+ */
47
+class CI_DB_cubrid_utility extends CI_DB_utility {
48
+
49
+	/**
50
+	 * List databases
51
+	 *
52
+	 * @return	array
53
+	 */
54
+	public function list_databases()
55
+	{
56
+		if (isset($this->db->data_cache['db_names']))
57
+		{
58
+			return $this->db->data_cache['db_names'];
59
+		}
60
+
61
+		return $this->db->data_cache['db_names'] = cubrid_list_dbs($this->db->conn_id);
62
+	}
63
+
64
+	// --------------------------------------------------------------------
65
+
66
+	/**
67
+	 * CUBRID Export
68
+	 *
69
+	 * @param	array	Preferences
70
+	 * @return	mixed
71
+	 */
72
+	protected function _backup($params = array())
73
+	{
74
+		// No SQL based support in CUBRID as of version 8.4.0. Database or
75
+		// table backup can be performed using CUBRID Manager
76
+		// database administration tool.
77
+		return $this->db->display_error('db_unsupported_feature');
78
+	}
79
+}

+ 11 - 0
system/database/drivers/cubrid/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 413 - 0
system/database/drivers/ibase/ibase_driver.php Datei anzeigen

@@ -0,0 +1,413 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 3.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Firebird/Interbase Database Adapter Class
42
+ *
43
+ * Note: _DB is an extender class that the app controller
44
+ * creates dynamically based on whether the query builder
45
+ * class is being used or not.
46
+ *
47
+ * @package		CodeIgniter
48
+ * @subpackage	Drivers
49
+ * @category	Database
50
+ * @author		EllisLab Dev Team
51
+ * @link		https://codeigniter.com/user_guide/database/
52
+ */
53
+class CI_DB_ibase_driver extends CI_DB {
54
+
55
+	/**
56
+	 * Database driver
57
+	 *
58
+	 * @var	string
59
+	 */
60
+	public $dbdriver = 'ibase';
61
+
62
+	// --------------------------------------------------------------------
63
+
64
+	/**
65
+	 * ORDER BY random keyword
66
+	 *
67
+	 * @var	array
68
+	 */
69
+	protected $_random_keyword = array('RAND()', 'RAND()');
70
+
71
+	/**
72
+	 * IBase Transaction status flag
73
+	 *
74
+	 * @var	resource
75
+	 */
76
+	protected $_ibase_trans;
77
+
78
+	// --------------------------------------------------------------------
79
+
80
+	/**
81
+	 * Non-persistent database connection
82
+	 *
83
+	 * @param	bool	$persistent
84
+	 * @return	resource
85
+	 */
86
+	public function db_connect($persistent = FALSE)
87
+	{
88
+		return ($persistent === TRUE)
89
+			? ibase_pconnect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set)
90
+			: ibase_connect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
91
+	}
92
+
93
+	// --------------------------------------------------------------------
94
+
95
+	/**
96
+	 * Database version number
97
+	 *
98
+	 * @return	string
99
+	 */
100
+	public function version()
101
+	{
102
+		if (isset($this->data_cache['version']))
103
+		{
104
+			return $this->data_cache['version'];
105
+		}
106
+
107
+		if (($service = ibase_service_attach($this->hostname, $this->username, $this->password)))
108
+		{
109
+			$this->data_cache['version'] = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
110
+
111
+			// Don't keep the service open
112
+			ibase_service_detach($service);
113
+			return $this->data_cache['version'];
114
+		}
115
+
116
+		return FALSE;
117
+	}
118
+
119
+	// --------------------------------------------------------------------
120
+
121
+	/**
122
+	 * Execute the query
123
+	 *
124
+	 * @param	string	$sql	an SQL query
125
+	 * @return	resource
126
+	 */
127
+	protected function _execute($sql)
128
+	{
129
+		return ibase_query(isset($this->_ibase_trans) ? $this->_ibase_trans : $this->conn_id, $sql);
130
+	}
131
+
132
+	// --------------------------------------------------------------------
133
+
134
+	/**
135
+	 * Begin Transaction
136
+	 *
137
+	 * @return	bool
138
+	 */
139
+	protected function _trans_begin()
140
+	{
141
+		if (($trans_handle = ibase_trans($this->conn_id)) === FALSE)
142
+		{
143
+			return FALSE;
144
+		}
145
+
146
+		$this->_ibase_trans = $trans_handle;
147
+		return TRUE;
148
+	}
149
+
150
+	// --------------------------------------------------------------------
151
+
152
+	/**
153
+	 * Commit Transaction
154
+	 *
155
+	 * @return	bool
156
+	 */
157
+	protected function _trans_commit()
158
+	{
159
+		if (ibase_commit($this->_ibase_trans))
160
+		{
161
+			$this->_ibase_trans = NULL;
162
+			return TRUE;
163
+		}
164
+
165
+		return FALSE;
166
+	}
167
+
168
+	// --------------------------------------------------------------------
169
+
170
+	/**
171
+	 * Rollback Transaction
172
+	 *
173
+	 * @return	bool
174
+	 */
175
+	protected function _trans_rollback()
176
+	{
177
+		if (ibase_rollback($this->_ibase_trans))
178
+		{
179
+			$this->_ibase_trans = NULL;
180
+			return TRUE;
181
+		}
182
+
183
+		return FALSE;
184
+	}
185
+
186
+	// --------------------------------------------------------------------
187
+
188
+	/**
189
+	 * Affected Rows
190
+	 *
191
+	 * @return	int
192
+	 */
193
+	public function affected_rows()
194
+	{
195
+		return ibase_affected_rows($this->conn_id);
196
+	}
197
+
198
+	// --------------------------------------------------------------------
199
+
200
+	/**
201
+	 * Insert ID
202
+	 *
203
+	 * @param	string	$generator_name
204
+	 * @param	int	$inc_by
205
+	 * @return	int
206
+	 */
207
+	public function insert_id($generator_name, $inc_by = 0)
208
+	{
209
+		//If a generator hasn't been used before it will return 0
210
+		return ibase_gen_id('"'.$generator_name.'"', $inc_by);
211
+	}
212
+
213
+	// --------------------------------------------------------------------
214
+
215
+	/**
216
+	 * List table query
217
+	 *
218
+	 * Generates a platform-specific query string so that the table names can be fetched
219
+	 *
220
+	 * @param	bool	$prefix_limit
221
+	 * @return	string
222
+	 */
223
+	protected function _list_tables($prefix_limit = FALSE)
224
+	{
225
+		$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$%\'';
226
+
227
+		if ($prefix_limit !== FALSE && $this->dbprefix !== '')
228
+		{
229
+			return $sql.' AND TRIM("RDB$RELATION_NAME") AS TABLE_NAME LIKE \''.$this->escape_like_str($this->dbprefix)."%' "
230
+				.sprintf($this->_like_escape_str, $this->_like_escape_chr);
231
+		}
232
+
233
+		return $sql;
234
+	}
235
+
236
+	// --------------------------------------------------------------------
237
+
238
+	/**
239
+	 * Show column query
240
+	 *
241
+	 * Generates a platform-specific query string so that the column names can be fetched
242
+	 *
243
+	 * @param	string	$table
244
+	 * @return	string
245
+	 */
246
+	protected function _list_columns($table = '')
247
+	{
248
+		return 'SELECT TRIM("RDB$FIELD_NAME") AS COLUMN_NAME FROM "RDB$RELATION_FIELDS" WHERE "RDB$RELATION_NAME" = '.$this->escape($table);
249
+	}
250
+
251
+	// --------------------------------------------------------------------
252
+
253
+	/**
254
+	 * Returns an object with field data
255
+	 *
256
+	 * @param	string	$table
257
+	 * @return	array
258
+	 */
259
+	public function field_data($table)
260
+	{
261
+		$sql = 'SELECT "rfields"."RDB$FIELD_NAME" AS "name",
262
+				CASE "fields"."RDB$FIELD_TYPE"
263
+					WHEN 7 THEN \'SMALLINT\'
264
+					WHEN 8 THEN \'INTEGER\'
265
+					WHEN 9 THEN \'QUAD\'
266
+					WHEN 10 THEN \'FLOAT\'
267
+					WHEN 11 THEN \'DFLOAT\'
268
+					WHEN 12 THEN \'DATE\'
269
+					WHEN 13 THEN \'TIME\'
270
+					WHEN 14 THEN \'CHAR\'
271
+					WHEN 16 THEN \'INT64\'
272
+					WHEN 27 THEN \'DOUBLE\'
273
+					WHEN 35 THEN \'TIMESTAMP\'
274
+					WHEN 37 THEN \'VARCHAR\'
275
+					WHEN 40 THEN \'CSTRING\'
276
+					WHEN 261 THEN \'BLOB\'
277
+					ELSE NULL
278
+				END AS "type",
279
+				"fields"."RDB$FIELD_LENGTH" AS "max_length",
280
+				"rfields"."RDB$DEFAULT_VALUE" AS "default"
281
+			FROM "RDB$RELATION_FIELDS" "rfields"
282
+				JOIN "RDB$FIELDS" "fields" ON "rfields"."RDB$FIELD_SOURCE" = "fields"."RDB$FIELD_NAME"
283
+			WHERE "rfields"."RDB$RELATION_NAME" = '.$this->escape($table).'
284
+			ORDER BY "rfields"."RDB$FIELD_POSITION"';
285
+
286
+		return (($query = $this->query($sql)) !== FALSE)
287
+			? $query->result_object()
288
+			: FALSE;
289
+	}
290
+
291
+	// --------------------------------------------------------------------
292
+
293
+	/**
294
+	 * Error
295
+	 *
296
+	 * Returns an array containing code and message of the last
297
+	 * database error that has occurred.
298
+	 *
299
+	 * @return	array
300
+	 */
301
+	public function error()
302
+	{
303
+		return array('code' => ibase_errcode(), 'message' => ibase_errmsg());
304
+	}
305
+
306
+	// --------------------------------------------------------------------
307
+
308
+	/**
309
+	 * Update statement
310
+	 *
311
+	 * Generates a platform-specific update string from the supplied data
312
+	 *
313
+	 * @param	string	$table
314
+	 * @param	array	$values
315
+	 * @return	string
316
+	 */
317
+	protected function _update($table, $values)
318
+	{
319
+		$this->qb_limit = FALSE;
320
+		return parent::_update($table, $values);
321
+	}
322
+
323
+	// --------------------------------------------------------------------
324
+
325
+	/**
326
+	 * Truncate statement
327
+	 *
328
+	 * Generates a platform-specific truncate string from the supplied data
329
+	 *
330
+	 * If the database does not support the TRUNCATE statement,
331
+	 * then this method maps to 'DELETE FROM table'
332
+	 *
333
+	 * @param	string	$table
334
+	 * @return	string
335
+	 */
336
+	protected function _truncate($table)
337
+	{
338
+		return 'DELETE FROM '.$table;
339
+	}
340
+
341
+	// --------------------------------------------------------------------
342
+
343
+	/**
344
+	 * Delete statement
345
+	 *
346
+	 * Generates a platform-specific delete string from the supplied data
347
+	 *
348
+	 * @param	string	$table
349
+	 * @return	string
350
+	 */
351
+	protected function _delete($table)
352
+	{
353
+		$this->qb_limit = FALSE;
354
+		return parent::_delete($table);
355
+	}
356
+
357
+	// --------------------------------------------------------------------
358
+
359
+	/**
360
+	 * LIMIT
361
+	 *
362
+	 * Generates a platform-specific LIMIT clause
363
+	 *
364
+	 * @param	string	$sql	SQL Query
365
+	 * @return	string
366
+	 */
367
+	protected function _limit($sql)
368
+	{
369
+		// Limit clause depends on if Interbase or Firebird
370
+		if (stripos($this->version(), 'firebird') !== FALSE)
371
+		{
372
+			$select = 'FIRST '.$this->qb_limit
373
+				.($this->qb_offset ? ' SKIP '.$this->qb_offset : '');
374
+		}
375
+		else
376
+		{
377
+			$select = 'ROWS '
378
+				.($this->qb_offset ? $this->qb_offset.' TO '.($this->qb_limit + $this->qb_offset) : $this->qb_limit);
379
+		}
380
+
381
+		return preg_replace('`SELECT`i', 'SELECT '.$select, $sql, 1);
382
+	}
383
+
384
+	// --------------------------------------------------------------------
385
+
386
+	/**
387
+	 * Insert batch statement
388
+	 *
389
+	 * Generates a platform-specific insert string from the supplied data.
390
+	 *
391
+	 * @param	string	$table	Table name
392
+	 * @param	array	$keys	INSERT keys
393
+	 * @param	array	$values	INSERT values
394
+	 * @return	string|bool
395
+	 */
396
+	protected function _insert_batch($table, $keys, $values)
397
+	{
398
+		return ($this->db_debug) ? $this->display_error('db_unsupported_feature') : FALSE;
399
+	}
400
+
401
+	// --------------------------------------------------------------------
402
+
403
+	/**
404
+	 * Close DB Connection
405
+	 *
406
+	 * @return	void
407
+	 */
408
+	protected function _close()
409
+	{
410
+		ibase_close($this->conn_id);
411
+	}
412
+
413
+}

+ 251 - 0
system/database/drivers/ibase/ibase_forge.php Datei anzeigen

@@ -0,0 +1,251 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 3.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Interbase/Firebird Forge Class
42
+ *
43
+ * @category	Database
44
+ * @author		EllisLab Dev Team
45
+ * @link		https://codeigniter.com/user_guide/database/
46
+ */
47
+class CI_DB_ibase_forge extends CI_DB_forge {
48
+
49
+	/**
50
+	 * CREATE TABLE IF statement
51
+	 *
52
+	 * @var	string
53
+	 */
54
+	protected $_create_table_if	= FALSE;
55
+
56
+	/**
57
+	 * RENAME TABLE statement
58
+	 *
59
+	 * @var	string
60
+	 */
61
+	protected $_rename_table	= FALSE;
62
+
63
+	/**
64
+	 * DROP TABLE IF statement
65
+	 *
66
+	 * @var	string
67
+	 */
68
+	protected $_drop_table_if	= FALSE;
69
+
70
+	/**
71
+	 * UNSIGNED support
72
+	 *
73
+	 * @var	array
74
+	 */
75
+	protected $_unsigned		= array(
76
+		'SMALLINT'	=> 'INTEGER',
77
+		'INTEGER'	=> 'INT64',
78
+		'FLOAT'		=> 'DOUBLE PRECISION'
79
+	);
80
+
81
+	/**
82
+	 * NULL value representation in CREATE/ALTER TABLE statements
83
+	 *
84
+	 * @var	string
85
+	 */
86
+	protected $_null		= 'NULL';
87
+
88
+	// --------------------------------------------------------------------
89
+
90
+	/**
91
+	 * Create database
92
+	 *
93
+	 * @param	string	$db_name
94
+	 * @return	bool
95
+	 */
96
+	public function create_database($db_name)
97
+	{
98
+		// Firebird databases are flat files, so a path is required
99
+
100
+		// Hostname is needed for remote access
101
+		empty($this->db->hostname) OR $db_name = $this->hostname.':'.$db_name;
102
+
103
+		return parent::create_database('"'.$db_name.'"');
104
+	}
105
+
106
+	// --------------------------------------------------------------------
107
+
108
+	/**
109
+	 * Drop database
110
+	 *
111
+	 * @param	string	$db_name	(ignored)
112
+	 * @return	bool
113
+	 */
114
+	public function drop_database($db_name)
115
+	{
116
+		if ( ! ibase_drop_db($this->conn_id))
117
+		{
118
+			return ($this->db->db_debug) ? $this->db->display_error('db_unable_to_drop') : FALSE;
119
+		}
120
+		elseif ( ! empty($this->db->data_cache['db_names']))
121
+		{
122
+			$key = array_search(strtolower($this->db->database), array_map('strtolower', $this->db->data_cache['db_names']), TRUE);
123
+			if ($key !== FALSE)
124
+			{
125
+				unset($this->db->data_cache['db_names'][$key]);
126
+			}
127
+		}
128
+
129
+		return TRUE;
130
+	}
131
+
132
+	// --------------------------------------------------------------------
133
+
134
+	/**
135
+	 * ALTER TABLE
136
+	 *
137
+	 * @param	string	$alter_type	ALTER type
138
+	 * @param	string	$table		Table name
139
+	 * @param	mixed	$field		Column definition
140
+	 * @return	string|string[]
141
+	 */
142
+	protected function _alter_table($alter_type, $table, $field)
143
+ 	{
144
+		if (in_array($alter_type, array('DROP', 'ADD'), TRUE))
145
+		{
146
+			return parent::_alter_table($alter_type, $table, $field);
147
+		}
148
+
149
+		$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table);
150
+		$sqls = array();
151
+		for ($i = 0, $c = count($field); $i < $c; $i++)
152
+		{
153
+			if ($field[$i]['_literal'] !== FALSE)
154
+			{
155
+				return FALSE;
156
+			}
157
+
158
+			if (isset($field[$i]['type']))
159
+			{
160
+				$sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identififers($field[$i]['name'])
161
+					.' TYPE '.$field[$i]['type'].$field[$i]['length'];
162
+			}
163
+
164
+			if ( ! empty($field[$i]['default']))
165
+			{
166
+				$sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
167
+					.' SET DEFAULT '.$field[$i]['default'];
168
+			}
169
+
170
+			if (isset($field[$i]['null']))
171
+			{
172
+				$sqls[] = 'UPDATE "RDB$RELATION_FIELDS" SET "RDB$NULL_FLAG" = '
173
+					.($field[$i]['null'] === TRUE ? 'NULL' : '1')
174
+					.' WHERE "RDB$FIELD_NAME" = '.$this->db->escape($field[$i]['name'])
175
+					.' AND "RDB$RELATION_NAME" = '.$this->db->escape($table);
176
+			}
177
+
178
+			if ( ! empty($field[$i]['new_name']))
179
+			{
180
+				$sqls[] = $sql.' ALTER COLUMN '.$this->db->escape_identifiers($field[$i]['name'])
181
+					.' TO '.$this->db->escape_identifiers($field[$i]['new_name']);
182
+			}
183
+		}
184
+
185
+		return $sqls;
186
+ 	}
187
+
188
+	// --------------------------------------------------------------------
189
+
190
+	/**
191
+	 * Process column
192
+	 *
193
+	 * @param	array	$field
194
+	 * @return	string
195
+	 */
196
+	protected function _process_column($field)
197
+	{
198
+		return $this->db->escape_identifiers($field['name'])
199
+			.' '.$field['type'].$field['length']
200
+			.$field['null']
201
+			.$field['unique']
202
+			.$field['default'];
203
+	}
204
+
205
+	// --------------------------------------------------------------------
206
+
207
+	/**
208
+	 * Field attribute TYPE
209
+	 *
210
+	 * Performs a data type mapping between different databases.
211
+	 *
212
+	 * @param	array	&$attributes
213
+	 * @return	void
214
+	 */
215
+	protected function _attr_type(&$attributes)
216
+	{
217
+		switch (strtoupper($attributes['TYPE']))
218
+		{
219
+			case 'TINYINT':
220
+				$attributes['TYPE'] = 'SMALLINT';
221
+				$attributes['UNSIGNED'] = FALSE;
222
+				return;
223
+			case 'MEDIUMINT':
224
+				$attributes['TYPE'] = 'INTEGER';
225
+				$attributes['UNSIGNED'] = FALSE;
226
+				return;
227
+			case 'INT':
228
+				$attributes['TYPE'] = 'INTEGER';
229
+				return;
230
+			case 'BIGINT':
231
+				$attributes['TYPE'] = 'INT64';
232
+				return;
233
+			default: return;
234
+		}
235
+	}
236
+
237
+	// --------------------------------------------------------------------
238
+
239
+	/**
240
+	 * Field attribute AUTO_INCREMENT
241
+	 *
242
+	 * @param	array	&$attributes
243
+	 * @param	array	&$field
244
+	 * @return	void
245
+	 */
246
+	protected function _attr_auto_increment(&$attributes, &$field)
247
+	{
248
+		// Not supported
249
+	}
250
+
251
+}

+ 161 - 0
system/database/drivers/ibase/ibase_result.php Datei anzeigen

@@ -0,0 +1,161 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 3.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Interbase/Firebird Result Class
42
+ *
43
+ * This class extends the parent result class: CI_DB_result
44
+ *
45
+ * @category	Database
46
+ * @author		EllisLab Dev Team
47
+ * @link		https://codeigniter.com/user_guide/database/
48
+ */
49
+class CI_DB_ibase_result extends CI_DB_result {
50
+
51
+	/**
52
+	 * Number of fields in the result set
53
+	 *
54
+	 * @return	int
55
+	 */
56
+	public function num_fields()
57
+	{
58
+		return ibase_num_fields($this->result_id);
59
+	}
60
+
61
+	// --------------------------------------------------------------------
62
+
63
+	/**
64
+	 * Fetch Field Names
65
+	 *
66
+	 * Generates an array of column names
67
+	 *
68
+	 * @return	array
69
+	 */
70
+	public function list_fields()
71
+	{
72
+		$field_names = array();
73
+		for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++)
74
+		{
75
+			$info = ibase_field_info($this->result_id, $i);
76
+			$field_names[] = $info['name'];
77
+		}
78
+
79
+		return $field_names;
80
+	}
81
+
82
+	// --------------------------------------------------------------------
83
+
84
+	/**
85
+	 * Field data
86
+	 *
87
+	 * Generates an array of objects containing field meta-data
88
+	 *
89
+	 * @return	array
90
+	 */
91
+	public function field_data()
92
+	{
93
+		$retval = array();
94
+		for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
95
+		{
96
+			$info = ibase_field_info($this->result_id, $i);
97
+
98
+			$retval[$i]			= new stdClass();
99
+			$retval[$i]->name		= $info['name'];
100
+			$retval[$i]->type		= $info['type'];
101
+			$retval[$i]->max_length		= $info['length'];
102
+		}
103
+
104
+		return $retval;
105
+	}
106
+
107
+	// --------------------------------------------------------------------
108
+
109
+	/**
110
+	 * Free the result
111
+	 *
112
+	 * @return	void
113
+	 */
114
+	public function free_result()
115
+	{
116
+		ibase_free_result($this->result_id);
117
+	}
118
+
119
+	// --------------------------------------------------------------------
120
+
121
+	/**
122
+	 * Result - associative array
123
+	 *
124
+	 * Returns the result set as an array
125
+	 *
126
+	 * @return	array
127
+	 */
128
+	protected function _fetch_assoc()
129
+	{
130
+		return ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS);
131
+	}
132
+
133
+	// --------------------------------------------------------------------
134
+
135
+	/**
136
+	 * Result - object
137
+	 *
138
+	 * Returns the result set as an object
139
+	 *
140
+	 * @param	string	$class_name
141
+	 * @return	object
142
+	 */
143
+	protected function _fetch_object($class_name = 'stdClass')
144
+	{
145
+		$row = ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS);
146
+
147
+		if ($class_name === 'stdClass' OR ! $row)
148
+		{
149
+			return $row;
150
+		}
151
+
152
+		$class_name = new $class_name();
153
+		foreach ($row as $key => $value)
154
+		{
155
+			$class_name->$key = $value;
156
+		}
157
+
158
+		return $class_name;
159
+	}
160
+
161
+}

+ 69 - 0
system/database/drivers/ibase/ibase_utility.php Datei anzeigen

@@ -0,0 +1,69 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 3.0.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * Interbase/Firebird Utility Class
42
+ *
43
+ * @category	Database
44
+ * @author		EllisLab Dev Team
45
+ * @link		https://codeigniter.com/user_guide/database/
46
+ */
47
+class CI_DB_ibase_utility extends CI_DB_utility {
48
+
49
+	/**
50
+	 * Export
51
+	 *
52
+	 * @param	string	$filename
53
+	 * @return	mixed
54
+	 */
55
+	protected function _backup($filename)
56
+	{
57
+		if ($service = ibase_service_attach($this->db->hostname, $this->db->username, $this->db->password))
58
+		{
59
+			$res = ibase_backup($service, $this->db->database, $filename.'.fbk');
60
+
61
+			// Close the service connection
62
+			ibase_service_detach($service);
63
+			return $res;
64
+		}
65
+
66
+		return FALSE;
67
+	}
68
+
69
+}

+ 11 - 0
system/database/drivers/ibase/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
system/database/drivers/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 11 - 0
system/database/drivers/mssql/index.html Datei anzeigen

@@ -0,0 +1,11 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+	<title>403 Forbidden</title>
5
+</head>
6
+<body>
7
+
8
+<p>Directory access is forbidden.</p>
9
+
10
+</body>
11
+</html>

+ 518 - 0
system/database/drivers/mssql/mssql_driver.php Datei anzeigen

@@ -0,0 +1,518 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.3.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * MS SQL Database Adapter Class
42
+ *
43
+ * Note: _DB is an extender class that the app controller
44
+ * creates dynamically based on whether the query builder
45
+ * class is being used or not.
46
+ *
47
+ * @package		CodeIgniter
48
+ * @subpackage	Drivers
49
+ * @category	Database
50
+ * @author		EllisLab Dev Team
51
+ * @link		https://codeigniter.com/user_guide/database/
52
+ */
53
+class CI_DB_mssql_driver extends CI_DB {
54
+
55
+	/**
56
+	 * Database driver
57
+	 *
58
+	 * @var	string
59
+	 */
60
+	public $dbdriver = 'mssql';
61
+
62
+	// --------------------------------------------------------------------
63
+
64
+	/**
65
+	 * ORDER BY random keyword
66
+	 *
67
+	 * @var	array
68
+	 */
69
+	protected $_random_keyword = array('NEWID()', 'RAND(%d)');
70
+
71
+	/**
72
+	 * Quoted identifier flag
73
+	 *
74
+	 * Whether to use SQL-92 standard quoted identifier
75
+	 * (double quotes) or brackets for identifier escaping.
76
+	 *
77
+	 * @var	bool
78
+	 */
79
+	protected $_quoted_identifier = TRUE;
80
+
81
+	// --------------------------------------------------------------------
82
+
83
+	/**
84
+	 * Class constructor
85
+	 *
86
+	 * Appends the port number to the hostname, if needed.
87
+	 *
88
+	 * @param	array	$params
89
+	 * @return	void
90
+	 */
91
+	public function __construct($params)
92
+	{
93
+		parent::__construct($params);
94
+
95
+		if ( ! empty($this->port))
96
+		{
97
+			$this->hostname .= (DIRECTORY_SEPARATOR === '\\' ? ',' : ':').$this->port;
98
+		}
99
+	}
100
+
101
+	// --------------------------------------------------------------------
102
+
103
+	/**
104
+	 * Non-persistent database connection
105
+	 *
106
+	 * @param	bool	$persistent
107
+	 * @return	resource
108
+	 */
109
+	public function db_connect($persistent = FALSE)
110
+	{
111
+		$this->conn_id = ($persistent)
112
+				? mssql_pconnect($this->hostname, $this->username, $this->password)
113
+				: mssql_connect($this->hostname, $this->username, $this->password);
114
+
115
+		if ( ! $this->conn_id)
116
+		{
117
+			return FALSE;
118
+		}
119
+
120
+		// ----------------------------------------------------------------
121
+
122
+		// Select the DB... assuming a database name is specified in the config file
123
+		if ($this->database !== '' && ! $this->db_select())
124
+		{
125
+			log_message('error', 'Unable to select database: '.$this->database);
126
+
127
+			return ($this->db_debug === TRUE)
128
+				? $this->display_error('db_unable_to_select', $this->database)
129
+				: FALSE;
130
+		}
131
+
132
+		// Determine how identifiers are escaped
133
+		$query = $this->query('SELECT CASE WHEN (@@OPTIONS | 256) = @@OPTIONS THEN 1 ELSE 0 END AS qi');
134
+		$query = $query->row_array();
135
+		$this->_quoted_identifier = empty($query) ? FALSE : (bool) $query['qi'];
136
+		$this->_escape_char = ($this->_quoted_identifier) ? '"' : array('[', ']');
137
+
138
+		return $this->conn_id;
139
+	}
140
+
141
+	// --------------------------------------------------------------------
142
+
143
+	/**
144
+	 * Select the database
145
+	 *
146
+	 * @param	string	$database
147
+	 * @return	bool
148
+	 */
149
+	public function db_select($database = '')
150
+	{
151
+		if ($database === '')
152
+		{
153
+			$database = $this->database;
154
+		}
155
+
156
+		// Note: Escaping is required in the event that the DB name
157
+		// contains reserved characters.
158
+		if (mssql_select_db('['.$database.']', $this->conn_id))
159
+		{
160
+			$this->database = $database;
161
+			$this->data_cache = array();
162
+			return TRUE;
163
+		}
164
+
165
+		return FALSE;
166
+	}
167
+
168
+	// --------------------------------------------------------------------
169
+
170
+	/**
171
+	 * Execute the query
172
+	 *
173
+	 * @param	string	$sql	an SQL query
174
+	 * @return	mixed	resource if rows are returned, bool otherwise
175
+	 */
176
+	protected function _execute($sql)
177
+	{
178
+		return mssql_query($sql, $this->conn_id);
179
+	}
180
+
181
+	// --------------------------------------------------------------------
182
+
183
+	/**
184
+	 * Begin Transaction
185
+	 *
186
+	 * @return	bool
187
+	 */
188
+	protected function _trans_begin()
189
+	{
190
+		return $this->simple_query('BEGIN TRAN');
191
+	}
192
+
193
+	// --------------------------------------------------------------------
194
+
195
+	/**
196
+	 * Commit Transaction
197
+	 *
198
+	 * @return	bool
199
+	 */
200
+	protected function _trans_commit()
201
+	{
202
+		return $this->simple_query('COMMIT TRAN');
203
+	}
204
+
205
+	// --------------------------------------------------------------------
206
+
207
+	/**
208
+	 * Rollback Transaction
209
+	 *
210
+	 * @return	bool
211
+	 */
212
+	protected function _trans_rollback()
213
+	{
214
+		return $this->simple_query('ROLLBACK TRAN');
215
+	}
216
+
217
+	// --------------------------------------------------------------------
218
+
219
+	/**
220
+	 * Affected Rows
221
+	 *
222
+	 * @return	int
223
+	 */
224
+	public function affected_rows()
225
+	{
226
+		return mssql_rows_affected($this->conn_id);
227
+	}
228
+
229
+	// --------------------------------------------------------------------
230
+
231
+	/**
232
+	 * Insert ID
233
+	 *
234
+	 * Returns the last id created in the Identity column.
235
+	 *
236
+	 * @return	string
237
+	 */
238
+	public function insert_id()
239
+	{
240
+		$query = version_compare($this->version(), '8', '>=')
241
+			? 'SELECT SCOPE_IDENTITY() AS last_id'
242
+			: 'SELECT @@IDENTITY AS last_id';
243
+
244
+		$query = $this->query($query);
245
+		$query = $query->row();
246
+		return $query->last_id;
247
+	}
248
+
249
+	// --------------------------------------------------------------------
250
+
251
+	/**
252
+	 * Set client character set
253
+	 *
254
+	 * @param	string	$charset
255
+	 * @return	bool
256
+	 */
257
+	protected function _db_set_charset($charset)
258
+	{
259
+		return (ini_set('mssql.charset', $charset) !== FALSE);
260
+	}
261
+
262
+	// --------------------------------------------------------------------
263
+
264
+	/**
265
+	 * Version number query string
266
+	 *
267
+	 * @return	string
268
+	 */
269
+	protected function _version()
270
+	{
271
+		return "SELECT SERVERPROPERTY('ProductVersion') AS ver";
272
+	}
273
+
274
+	// --------------------------------------------------------------------
275
+
276
+	/**
277
+	 * List table query
278
+	 *
279
+	 * Generates a platform-specific query string so that the table names can be fetched
280
+	 *
281
+	 * @param	bool	$prefix_limit
282
+	 * @return	string
283
+	 */
284
+	protected function _list_tables($prefix_limit = FALSE)
285
+	{
286
+		$sql = 'SELECT '.$this->escape_identifiers('name')
287
+			.' FROM '.$this->escape_identifiers('sysobjects')
288
+			.' WHERE '.$this->escape_identifiers('type')." = 'U'";
289
+
290
+		if ($prefix_limit !== FALSE && $this->dbprefix !== '')
291
+		{
292
+			$sql .= ' AND '.$this->escape_identifiers('name')." LIKE '".$this->escape_like_str($this->dbprefix)."%' "
293
+				.sprintf($this->_like_escape_str, $this->_like_escape_chr);
294
+		}
295
+
296
+		return $sql.' ORDER BY '.$this->escape_identifiers('name');
297
+	}
298
+
299
+	// --------------------------------------------------------------------
300
+
301
+	/**
302
+	 * List column query
303
+	 *
304
+	 * Generates a platform-specific query string so that the column names can be fetched
305
+	 *
306
+	 * @param	string	$table
307
+	 * @return	string
308
+	 */
309
+	protected function _list_columns($table = '')
310
+	{
311
+		return 'SELECT COLUMN_NAME
312
+			FROM INFORMATION_SCHEMA.Columns
313
+			WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table));
314
+	}
315
+
316
+	// --------------------------------------------------------------------
317
+
318
+	/**
319
+	 * Returns an object with field data
320
+	 *
321
+	 * @param	string	$table
322
+	 * @return	array
323
+	 */
324
+	public function field_data($table)
325
+	{
326
+		$sql = 'SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION, COLUMN_DEFAULT
327
+			FROM INFORMATION_SCHEMA.Columns
328
+			WHERE UPPER(TABLE_NAME) = '.$this->escape(strtoupper($table));
329
+
330
+		if (($query = $this->query($sql)) === FALSE)
331
+		{
332
+			return FALSE;
333
+		}
334
+		$query = $query->result_object();
335
+
336
+		$retval = array();
337
+		for ($i = 0, $c = count($query); $i < $c; $i++)
338
+		{
339
+			$retval[$i]			= new stdClass();
340
+			$retval[$i]->name		= $query[$i]->COLUMN_NAME;
341
+			$retval[$i]->type		= $query[$i]->DATA_TYPE;
342
+			$retval[$i]->max_length		= ($query[$i]->CHARACTER_MAXIMUM_LENGTH > 0) ? $query[$i]->CHARACTER_MAXIMUM_LENGTH : $query[$i]->NUMERIC_PRECISION;
343
+			$retval[$i]->default		= $query[$i]->COLUMN_DEFAULT;
344
+		}
345
+
346
+		return $retval;
347
+	}
348
+
349
+	// --------------------------------------------------------------------
350
+
351
+	/**
352
+	 * Error
353
+	 *
354
+	 * Returns an array containing code and message of the last
355
+	 * database error that has occurred.
356
+	 *
357
+	 * @return	array
358
+	 */
359
+	public function error()
360
+	{
361
+		// We need this because the error info is discarded by the
362
+		// server the first time you request it, and query() already
363
+		// calls error() once for logging purposes when a query fails.
364
+		static $error = array('code' => 0, 'message' => NULL);
365
+
366
+		$message = mssql_get_last_message();
367
+		if ( ! empty($message))
368
+		{
369
+			$error['code']    = $this->query('SELECT @@ERROR AS code')->row()->code;
370
+			$error['message'] = $message;
371
+		}
372
+
373
+		return $error;
374
+	}
375
+
376
+	// --------------------------------------------------------------------
377
+
378
+	/**
379
+	 * Update statement
380
+	 *
381
+	 * Generates a platform-specific update string from the supplied data
382
+	 *
383
+	 * @param	string	$table
384
+	 * @param	array	$values
385
+	 * @return	string
386
+	 */
387
+	protected function _update($table, $values)
388
+	{
389
+		$this->qb_limit = FALSE;
390
+		$this->qb_orderby = array();
391
+		return parent::_update($table, $values);
392
+	}
393
+
394
+	// --------------------------------------------------------------------
395
+
396
+	/**
397
+	 * Truncate statement
398
+	 *
399
+	 * Generates a platform-specific truncate string from the supplied data
400
+	 *
401
+	 * If the database does not support the TRUNCATE statement,
402
+	 * then this method maps to 'DELETE FROM table'
403
+	 *
404
+	 * @param	string	$table
405
+	 * @return	string
406
+	 */
407
+	protected function _truncate($table)
408
+	{
409
+		return 'TRUNCATE TABLE '.$table;
410
+	}
411
+
412
+	// --------------------------------------------------------------------
413
+
414
+	/**
415
+	 * Delete statement
416
+	 *
417
+	 * Generates a platform-specific delete string from the supplied data
418
+	 *
419
+	 * @param	string	$table
420
+	 * @return	string
421
+	 */
422
+	protected function _delete($table)
423
+	{
424
+		if ($this->qb_limit)
425
+		{
426
+			return 'WITH ci_delete AS (SELECT TOP '.$this->qb_limit.' * FROM '.$table.$this->_compile_wh('qb_where').') DELETE FROM ci_delete';
427
+		}
428
+
429
+		return parent::_delete($table);
430
+	}
431
+
432
+	// --------------------------------------------------------------------
433
+
434
+	/**
435
+	 * LIMIT
436
+	 *
437
+	 * Generates a platform-specific LIMIT clause
438
+	 *
439
+	 * @param	string	$sql	SQL Query
440
+	 * @return	string
441
+	 */
442
+	protected function _limit($sql)
443
+	{
444
+		$limit = $this->qb_offset + $this->qb_limit;
445
+
446
+		// As of SQL Server 2005 (9.0.*) ROW_NUMBER() is supported,
447
+		// however an ORDER BY clause is required for it to work
448
+		if (version_compare($this->version(), '9', '>=') && $this->qb_offset && ! empty($this->qb_orderby))
449
+		{
450
+			$orderby = $this->_compile_order_by();
451
+
452
+			// We have to strip the ORDER BY clause
453
+			$sql = trim(substr($sql, 0, strrpos($sql, $orderby)));
454
+
455
+			// Get the fields to select from our subquery, so that we can avoid CI_rownum appearing in the actual results
456
+			if (count($this->qb_select) === 0 OR strpos(implode(',', $this->qb_select), '*') !== FALSE)
457
+			{
458
+				$select = '*'; // Inevitable
459
+			}
460
+			else
461
+			{
462
+				// Use only field names and their aliases, everything else is out of our scope.
463
+				$select = array();
464
+				$field_regexp = ($this->_quoted_identifier)
465
+					? '("[^\"]+")' : '(\[[^\]]+\])';
466
+				for ($i = 0, $c = count($this->qb_select); $i < $c; $i++)
467
+				{
468
+					$select[] = preg_match('/(?:\s|\.)'.$field_regexp.'$/i', $this->qb_select[$i], $m)
469
+						? $m[1] : $this->qb_select[$i];
470
+				}
471
+				$select = implode(', ', $select);
472
+			}
473
+
474
+			return 'SELECT '.$select." FROM (\n\n"
475
+				.preg_replace('/^(SELECT( DISTINCT)?)/i', '\\1 ROW_NUMBER() OVER('.trim($orderby).') AS '.$this->escape_identifiers('CI_rownum').', ', $sql)
476
+				."\n\n) ".$this->escape_identifiers('CI_subquery')
477
+				."\nWHERE ".$this->escape_identifiers('CI_rownum').' BETWEEN '.($this->qb_offset + 1).' AND '.$limit;
478
+		}
479
+
480
+		return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$limit.' ', $sql);
481
+	}
482
+
483
+	// --------------------------------------------------------------------
484
+
485
+	/**
486
+	 * Insert batch statement
487
+	 *
488
+	 * Generates a platform-specific insert string from the supplied data.
489
+	 *
490
+	 * @param	string	$table	Table name
491
+	 * @param	array	$keys	INSERT keys
492
+	 * @param	array	$values	INSERT values
493
+	 * @return	string|bool
494
+	 */
495
+	protected function _insert_batch($table, $keys, $values)
496
+	{
497
+		// Multiple-value inserts are only supported as of SQL Server 2008
498
+		if (version_compare($this->version(), '10', '>='))
499
+		{
500
+			return parent::_insert_batch($table, $keys, $values);
501
+		}
502
+
503
+		return ($this->db_debug) ? $this->display_error('db_unsupported_feature') : FALSE;
504
+	}
505
+
506
+	// --------------------------------------------------------------------
507
+
508
+	/**
509
+	 * Close DB Connection
510
+	 *
511
+	 * @return	void
512
+	 */
513
+	protected function _close()
514
+	{
515
+		mssql_close($this->conn_id);
516
+	}
517
+
518
+}

+ 151 - 0
system/database/drivers/mssql/mssql_forge.php Datei anzeigen

@@ -0,0 +1,151 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.3.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * MS SQL Forge Class
42
+ *
43
+ * @package		CodeIgniter
44
+ * @subpackage	Drivers
45
+ * @category	Database
46
+ * @author		EllisLab Dev Team
47
+ * @link		https://codeigniter.com/user_guide/database/
48
+ */
49
+class CI_DB_mssql_forge extends CI_DB_forge {
50
+
51
+	/**
52
+	 * CREATE TABLE IF statement
53
+	 *
54
+	 * @var	string
55
+	 */
56
+	protected $_create_table_if	= "IF NOT EXISTS (SELECT * FROM sysobjects WHERE ID = object_id(N'%s') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)\nCREATE TABLE";
57
+
58
+	/**
59
+	 * DROP TABLE IF statement
60
+	 *
61
+	 * @var	string
62
+	 */
63
+	protected $_drop_table_if	= "IF EXISTS (SELECT * FROM sysobjects WHERE ID = object_id(N'%s') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)\nDROP TABLE";
64
+
65
+	/**
66
+	 * UNSIGNED support
67
+	 *
68
+	 * @var	array
69
+	 */
70
+	protected $_unsigned		= array(
71
+		'TINYINT'	=> 'SMALLINT',
72
+		'SMALLINT'	=> 'INT',
73
+		'INT'		=> 'BIGINT',
74
+		'REAL'		=> 'FLOAT'
75
+	);
76
+
77
+	// --------------------------------------------------------------------
78
+
79
+	/**
80
+	 * ALTER TABLE
81
+	 *
82
+	 * @param	string	$alter_type	ALTER type
83
+	 * @param	string	$table		Table name
84
+	 * @param	mixed	$field		Column definition
85
+	 * @return	string|string[]
86
+	 */
87
+	protected function _alter_table($alter_type, $table, $field)
88
+	{
89
+		if (in_array($alter_type, array('ADD', 'DROP'), TRUE))
90
+		{
91
+			return parent::_alter_table($alter_type, $table, $field);
92
+		}
93
+
94
+		$sql = 'ALTER TABLE '.$this->db->escape_identifiers($table).' ALTER COLUMN ';
95
+		$sqls = array();
96
+		for ($i = 0, $c = count($field); $i < $c; $i++)
97
+		{
98
+			$sqls[] = $sql.$this->_process_column($field[$i]);
99
+		}
100
+
101
+		return $sqls;
102
+	}
103
+
104
+	// --------------------------------------------------------------------
105
+
106
+	/**
107
+	 * Field attribute TYPE
108
+	 *
109
+	 * Performs a data type mapping between different databases.
110
+	 *
111
+	 * @param	array	&$attributes
112
+	 * @return	void
113
+	 */
114
+	protected function _attr_type(&$attributes)
115
+	{
116
+		if (isset($attributes['CONSTRAINT']) && strpos($attributes['TYPE'], 'INT') !== FALSE)
117
+		{
118
+			unset($attributes['CONSTRAINT']);
119
+		}
120
+
121
+		switch (strtoupper($attributes['TYPE']))
122
+		{
123
+			case 'MEDIUMINT':
124
+				$attributes['TYPE'] = 'INTEGER';
125
+				$attributes['UNSIGNED'] = FALSE;
126
+				return;
127
+			case 'INTEGER':
128
+				$attributes['TYPE'] = 'INT';
129
+				return;
130
+			default: return;
131
+		}
132
+	}
133
+
134
+	// --------------------------------------------------------------------
135
+
136
+	/**
137
+	 * Field attribute AUTO_INCREMENT
138
+	 *
139
+	 * @param	array	&$attributes
140
+	 * @param	array	&$field
141
+	 * @return	void
142
+	 */
143
+	protected function _attr_auto_increment(&$attributes, &$field)
144
+	{
145
+		if ( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE && stripos($field['type'], 'int') !== FALSE)
146
+		{
147
+			$field['auto_increment'] = ' IDENTITY(1,1)';
148
+		}
149
+	}
150
+
151
+}

+ 198 - 0
system/database/drivers/mssql/mssql_result.php Datei anzeigen

@@ -0,0 +1,198 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.3.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * MSSQL Result Class
42
+ *
43
+ * This class extends the parent result class: CI_DB_result
44
+ *
45
+ * @package		CodeIgniter
46
+ * @subpackage	Drivers
47
+ * @category	Database
48
+ * @author		EllisLab Dev Team
49
+ * @link		https://codeigniter.com/user_guide/database/
50
+ */
51
+class CI_DB_mssql_result extends CI_DB_result {
52
+
53
+	/**
54
+	 * Number of rows in the result set
55
+	 *
56
+	 * @return	int
57
+	 */
58
+	public function num_rows()
59
+	{
60
+		return is_int($this->num_rows)
61
+			? $this->num_rows
62
+			: $this->num_rows = mssql_num_rows($this->result_id);
63
+	}
64
+
65
+	// --------------------------------------------------------------------
66
+
67
+	/**
68
+	 * Number of fields in the result set
69
+	 *
70
+	 * @return	int
71
+	 */
72
+	public function num_fields()
73
+	{
74
+		return mssql_num_fields($this->result_id);
75
+	}
76
+
77
+	// --------------------------------------------------------------------
78
+
79
+	/**
80
+	 * Fetch Field Names
81
+	 *
82
+	 * Generates an array of column names
83
+	 *
84
+	 * @return	array
85
+	 */
86
+	public function list_fields()
87
+	{
88
+		$field_names = array();
89
+		mssql_field_seek($this->result_id, 0);
90
+		while ($field = mssql_fetch_field($this->result_id))
91
+		{
92
+			$field_names[] = $field->name;
93
+		}
94
+
95
+		return $field_names;
96
+	}
97
+
98
+	// --------------------------------------------------------------------
99
+
100
+	/**
101
+	 * Field data
102
+	 *
103
+	 * Generates an array of objects containing field meta-data
104
+	 *
105
+	 * @return	array
106
+	 */
107
+	public function field_data()
108
+	{
109
+		$retval = array();
110
+		for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
111
+		{
112
+			$field = mssql_fetch_field($this->result_id, $i);
113
+
114
+			$retval[$i]		= new stdClass();
115
+			$retval[$i]->name	= $field->name;
116
+			$retval[$i]->type	= $field->type;
117
+			$retval[$i]->max_length	= $field->max_length;
118
+		}
119
+
120
+		return $retval;
121
+	}
122
+
123
+	// --------------------------------------------------------------------
124
+
125
+	/**
126
+	 * Free the result
127
+	 *
128
+	 * @return	void
129
+	 */
130
+	public function free_result()
131
+	{
132
+		if (is_resource($this->result_id))
133
+		{
134
+			mssql_free_result($this->result_id);
135
+			$this->result_id = FALSE;
136
+		}
137
+	}
138
+
139
+	// --------------------------------------------------------------------
140
+
141
+	/**
142
+	 * Data Seek
143
+	 *
144
+	 * Moves the internal pointer to the desired offset. We call
145
+	 * this internally before fetching results to make sure the
146
+	 * result set starts at zero.
147
+	 *
148
+	 * @param	int	$n
149
+	 * @return	bool
150
+	 */
151
+	public function data_seek($n = 0)
152
+	{
153
+		return mssql_data_seek($this->result_id, $n);
154
+	}
155
+
156
+	// --------------------------------------------------------------------
157
+
158
+	/**
159
+	 * Result - associative array
160
+	 *
161
+	 * Returns the result set as an array
162
+	 *
163
+	 * @return	array
164
+	 */
165
+	protected function _fetch_assoc()
166
+	{
167
+		return mssql_fetch_assoc($this->result_id);
168
+	}
169
+
170
+	// --------------------------------------------------------------------
171
+
172
+	/**
173
+	 * Result - object
174
+	 *
175
+	 * Returns the result set as an object
176
+	 *
177
+	 * @param	string	$class_name
178
+	 * @return	object
179
+	 */
180
+	protected function _fetch_object($class_name = 'stdClass')
181
+	{
182
+		$row = mssql_fetch_object($this->result_id);
183
+
184
+		if ($class_name === 'stdClass' OR ! $row)
185
+		{
186
+			return $row;
187
+		}
188
+
189
+		$class_name = new $class_name();
190
+		foreach ($row as $key => $value)
191
+		{
192
+			$class_name->$key = $value;
193
+		}
194
+
195
+		return $class_name;
196
+	}
197
+
198
+}

+ 77 - 0
system/database/drivers/mssql/mssql_utility.php Datei anzeigen

@@ -0,0 +1,77 @@
1
+<?php
2
+/**
3
+ * CodeIgniter
4
+ *
5
+ * An open source application development framework for PHP
6
+ *
7
+ * This content is released under the MIT License (MIT)
8
+ *
9
+ * Copyright (c) 2014 - 2019, British Columbia Institute of Technology
10
+ *
11
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ * of this software and associated documentation files (the "Software"), to deal
13
+ * in the Software without restriction, including without limitation the rights
14
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ * copies of the Software, and to permit persons to whom the Software is
16
+ * furnished to do so, subject to the following conditions:
17
+ *
18
+ * The above copyright notice and this permission notice shall be included in
19
+ * all copies or substantial portions of the Software.
20
+ *
21
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ * THE SOFTWARE.
28
+ *
29
+ * @package	CodeIgniter
30
+ * @author	EllisLab Dev Team
31
+ * @copyright	Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright	Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
33
+ * @license	https://opensource.org/licenses/MIT	MIT License
34
+ * @link	https://codeigniter.com
35
+ * @since	Version 1.3.0
36
+ * @filesource
37
+ */
38
+defined('BASEPATH') OR exit('No direct script access allowed');
39
+
40
+/**
41
+ * MS SQL Utility Class
42
+ *
43
+ * @package		CodeIgniter
44
+ * @subpackage	Drivers
45
+ * @category	Database
46
+ * @author		EllisLab Dev Team
47
+ * @link		https://codeigniter.com/user_guide/database/
48
+ */
49
+class CI_DB_mssql_utility extends CI_DB_utility {
50
+
51
+	/**
52
+	 * List databases statement
53
+	 *
54
+	 * @var	string
55
+	 */
56
+	protected $_list_databases	= 'EXEC sp_helpdb'; // Can also be: EXEC sp_databases
57
+
58
+	/**
59
+	 * OPTIMIZE TABLE statement
60
+	 *
61
+	 * @var	string
62
+	 */
63
+	protected $_optimize_table	= 'ALTER INDEX all ON %s REORGANIZE';
64
+
65
+	/**
66
+	 * Export
67
+	 *
68
+	 * @param	array	$params	Preferences
69
+	 * @return	bool
70
+	 */
71
+	protected function _backup($params = array())
72
+	{
73
+		// Currently unsupported
74
+		return $this->db->display_error('db_unsupported_feature');
75
+	}
76
+
77
+}

+ 0 - 0
system/database/drivers/mysql/index.html Datei anzeigen


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.