├── .editorconfig ├── .gitignore ├── .htaccess ├── application ├── .htaccess ├── cache │ ├── .htaccess │ └── index.html ├── config │ ├── autoload.php │ ├── config.php │ ├── constants.php │ ├── database.php │ ├── doctypes.php │ ├── foreign_chars.php │ ├── hooks.php │ ├── index.html │ ├── jwt.php │ ├── memcached.php │ ├── migration.php │ ├── mimes.php │ ├── profiler.php │ ├── rest.php │ ├── routes.php │ ├── smileys.php │ └── user_agents.php ├── controllers │ ├── Welcome.php │ ├── api │ │ ├── Articles.php │ │ └── Users.php │ └── index.html ├── core │ └── index.html ├── helpers │ └── index.html ├── hooks │ └── index.html ├── index.html ├── language │ ├── bulgarian │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── dutch │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── english │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── french │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── german │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── greek │ │ └── rest_controller_lang.php │ ├── index.html │ ├── indonesia │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── italian │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── portuguese-brazilian │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── romanian │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── serbian_cyr │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── serbian_lat │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── simplified-chinese │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── spanish │ │ ├── index.html │ │ └── rest_controller_lang.php │ ├── traditional-chinese │ │ ├── index.html │ │ └── rest_controller_lang.php │ └── turkish │ │ ├── index.html │ │ └── rest_controller_lang.php ├── libraries │ ├── Authorization_Token.php │ ├── Format.php │ ├── REST_Controller.php │ └── index.html ├── logs │ └── index.html ├── models │ ├── Article_model.php │ ├── User_model.php │ └── index.html ├── third_party │ ├── index.html │ └── php-jwt │ │ ├── BeforeValidException.php │ │ ├── ExpiredException.php │ │ ├── JWT.php │ │ └── SignatureInvalidException.php └── views │ ├── errors │ ├── cli │ │ ├── error_404.php │ │ ├── error_db.php │ │ ├── error_exception.php │ │ ├── error_general.php │ │ ├── error_php.php │ │ └── index.html │ ├── html │ │ ├── error_404.php │ │ ├── error_db.php │ │ ├── error_exception.php │ │ ├── error_general.php │ │ ├── error_php.php │ │ └── index.html │ └── index.html │ ├── index.html │ └── welcome_message.php ├── composer.json ├── contributing.md ├── index.php ├── license.txt └── readme.md /.editorconfig: -------------------------------------------------------------------------------- 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 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | system 4 | application/cache/* 5 | !application/cache/index.html 6 | !application/cache/.htaccess 7 | 8 | application/logs/* 9 | !application/logs/index.html 10 | !application/logs/.htaccess 11 | 12 | composer.lock 13 | 14 | user_guide_src/build/* 15 | user_guide_src/cilexer/build/* 16 | user_guide_src/cilexer/dist/* 17 | user_guide_src/cilexer/pycilexer.egg-info/* 18 | /vendor/ 19 | 20 | # IDE Files 21 | #------------------------- 22 | /nbproject/ 23 | .idea/* 24 | 25 | ## Sublime Text cache files 26 | *.tmlanguage.cache 27 | *.tmPreferences.cache 28 | *.stTheme.cache 29 | *.sublime-workspace 30 | *.sublime-project 31 | -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | RewriteCond %{REQUEST_FILENAME} !-f 3 | RewriteCond %{REQUEST_FILENAME} !-d 4 | RewriteRule ^(.*)$ index.php/$1 [L] -------------------------------------------------------------------------------- /application/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Require all denied 3 | 4 | 5 | Deny from all 6 | -------------------------------------------------------------------------------- /application/cache/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Require all denied 3 | 4 | 5 | Deny from all 6 | -------------------------------------------------------------------------------- /application/cache/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/config/autoload.php: -------------------------------------------------------------------------------- 1 | 'ua'); 60 | */ 61 | $autoload['libraries'] = array('database', 'form_validation'); 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(); 136 | -------------------------------------------------------------------------------- /application/config/config.php: -------------------------------------------------------------------------------- 1 | ]+$/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'] = ''; 524 | -------------------------------------------------------------------------------- /application/config/constants.php: -------------------------------------------------------------------------------- 1 | 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' => 'root', 80 | 'password' => '', 81 | 'database' => 'restserver', 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 | ); 97 | -------------------------------------------------------------------------------- /application/config/doctypes.php: -------------------------------------------------------------------------------- 1 | '', 6 | 'xhtml1-strict' => '', 7 | 'xhtml1-trans' => '', 8 | 'xhtml1-frame' => '', 9 | 'xhtml-basic11' => '', 10 | 'html5' => '', 11 | 'html4-strict' => '', 12 | 'html4-trans' => '', 13 | 'html4-frame' => '', 14 | 'mathml1' => '', 15 | 'mathml2' => '', 16 | 'svg10' => '', 17 | 'svg11' => '', 18 | 'svg11-basic' => '', 19 | 'svg11-tiny' => '', 20 | 'xhtml-math-svg-xh' => '', 21 | 'xhtml-math-svg-sh' => '', 22 | 'xhtml-rdfa-1' => '', 23 | 'xhtml-rdfa-2' => '' 24 | ); 25 | -------------------------------------------------------------------------------- /application/config/foreign_chars.php: -------------------------------------------------------------------------------- 1 | '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 | '/Ķ|Κ|К/' => 'K', 42 | '/ķ|κ|к/' => 'k', 43 | '/Ĺ|Ļ|Ľ|Ŀ|Ł|Λ|Л/' => 'L', 44 | '/ĺ|ļ|ľ|ŀ|ł|λ|л/' => 'l', 45 | '/М/' => 'M', 46 | '/м/' => 'm', 47 | '/Ñ|Ń|Ņ|Ň|Ν|Н/' => 'N', 48 | '/ñ|ń|ņ|ň|ʼn|ν|н/' => 'n', 49 | '/Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|Ο|Ό|Ω|Ώ|Ỏ|Ọ|Ồ|Ố|Ỗ|Ổ|Ộ|Ờ|Ớ|Ỡ|Ở|Ợ|О/' => 'O', 50 | '/ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|ο|ό|ω|ώ|ỏ|ọ|ồ|ố|ỗ|ổ|ộ|ờ|ớ|ỡ|ở|ợ|о/' => 'o', 51 | '/П/' => 'P', 52 | '/п/' => 'p', 53 | '/Ŕ|Ŗ|Ř|Ρ|Р/' => 'R', 54 | '/ŕ|ŗ|ř|ρ|р/' => 'r', 55 | '/Ś|Ŝ|Ş|Ș|Š|Σ|С/' => 'S', 56 | '/ś|ŝ|ş|ș|š|ſ|σ|ς|с/' => 's', 57 | '/Ț|Ţ|Ť|Ŧ|τ|Т/' => 'T', 58 | '/ț|ţ|ť|ŧ|т/' => 't', 59 | '/Þ|þ/' => 'th', 60 | '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|Ũ|Ủ|Ụ|Ừ|Ứ|Ữ|Ử|Ự|У/' => 'U', 61 | '/ù|ú|û|ũ|ū|ŭ|ů|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|υ|ύ|ϋ|ủ|ụ|ừ|ứ|ữ|ử|ự|у/' => 'u', 62 | '/Ý|Ÿ|Ŷ|Υ|Ύ|Ϋ|Ỳ|Ỹ|Ỷ|Ỵ|Й/' => 'Y', 63 | '/ý|ÿ|ŷ|ỳ|ỹ|ỷ|ỵ|й/' => 'y', 64 | '/В/' => 'V', 65 | '/в/' => 'v', 66 | '/Ŵ/' => 'W', 67 | '/ŵ/' => 'w', 68 | '/Ź|Ż|Ž|Ζ|З/' => 'Z', 69 | '/ź|ż|ž|ζ|з/' => 'z', 70 | '/Æ|Ǽ/' => 'AE', 71 | '/ß/' => 'ss', 72 | '/IJ/' => 'IJ', 73 | '/ij/' => 'ij', 74 | '/Œ/' => 'OE', 75 | '/ƒ/' => 'f', 76 | '/ξ/' => 'ks', 77 | '/π/' => 'p', 78 | '/β/' => 'v', 79 | '/μ/' => 'm', 80 | '/ψ/' => 'ps', 81 | '/Ё/' => 'Yo', 82 | '/ё/' => 'yo', 83 | '/Є/' => 'Ye', 84 | '/є/' => 'ye', 85 | '/Ї/' => 'Yi', 86 | '/Ж/' => 'Zh', 87 | '/ж/' => 'zh', 88 | '/Х/' => 'Kh', 89 | '/х/' => 'kh', 90 | '/Ц/' => 'Ts', 91 | '/ц/' => 'ts', 92 | '/Ч/' => 'Ch', 93 | '/ч/' => 'ch', 94 | '/Ш/' => 'Sh', 95 | '/ш/' => 'sh', 96 | '/Щ/' => 'Shch', 97 | '/щ/' => 'shch', 98 | '/Ъ|ъ|Ь|ь/' => '', 99 | '/Ю/' => 'Yu', 100 | '/ю/' => 'yu', 101 | '/Я/' => 'Ya', 102 | '/я/' => 'ya' 103 | ); 104 | -------------------------------------------------------------------------------- /application/config/hooks.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/config/jwt.php: -------------------------------------------------------------------------------- 1 | array( 15 | 'hostname' => '127.0.0.1', 16 | 'port' => '11211', 17 | 'weight' => '1', 18 | ), 19 | ); 20 | -------------------------------------------------------------------------------- /application/config/migration.php: -------------------------------------------------------------------------------- 1 | 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/'; 85 | -------------------------------------------------------------------------------- /application/config/mimes.php: -------------------------------------------------------------------------------- 1 | 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' => 'audio/x-acc', 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 | '7zip' => array('application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'), 159 | 'cdr' => array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'), 160 | 'wma' => array('audio/x-ms-wma', 'video/x-ms-asf'), 161 | 'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'), 162 | 'svg' => array('image/svg+xml', 'application/xml', 'text/xml'), 163 | 'vcf' => 'text/x-vcard', 164 | 'srt' => array('text/srt', 'text/plain'), 165 | 'vtt' => array('text/vtt', 'text/plain'), 166 | 'ico' => array('image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon'), 167 | 'odc' => 'application/vnd.oasis.opendocument.chart', 168 | 'otc' => 'application/vnd.oasis.opendocument.chart-template', 169 | 'odf' => 'application/vnd.oasis.opendocument.formula', 170 | 'otf' => 'application/vnd.oasis.opendocument.formula-template', 171 | 'odg' => 'application/vnd.oasis.opendocument.graphics', 172 | 'otg' => 'application/vnd.oasis.opendocument.graphics-template', 173 | 'odi' => 'application/vnd.oasis.opendocument.image', 174 | 'oti' => 'application/vnd.oasis.opendocument.image-template', 175 | 'odp' => 'application/vnd.oasis.opendocument.presentation', 176 | 'otp' => 'application/vnd.oasis.opendocument.presentation-template', 177 | 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 178 | 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', 179 | 'odt' => 'application/vnd.oasis.opendocument.text', 180 | 'odm' => 'application/vnd.oasis.opendocument.text-master', 181 | 'ott' => 'application/vnd.oasis.opendocument.text-template', 182 | 'oth' => 'application/vnd.oasis.opendocument.text-web' 183 | ); 184 | -------------------------------------------------------------------------------- /application/config/profiler.php: -------------------------------------------------------------------------------- 1 | function($username, $password) 150 | | In other cases override the function _perform_library_auth in your controller 151 | | 152 | | For digest authentication the library function should return already a stored 153 | | md5(username:restrealm:password) for that username 154 | | 155 | | e.g: md5('admin:REST API:1234') = '1e957ebc35631ab22d5bd6526bd14ea2' 156 | | 157 | */ 158 | $config['auth_library_class'] = ''; 159 | $config['auth_library_function'] = ''; 160 | 161 | /* 162 | |-------------------------------------------------------------------------- 163 | | Override auth types for specific class/method 164 | |-------------------------------------------------------------------------- 165 | | 166 | | Set specific authentication types for methods within a class (controller) 167 | | 168 | | Set as many config entries as needed. Any methods not set will use the default 'rest_auth' config value. 169 | | 170 | | e.g: 171 | | 172 | | $config['auth_override_class_method']['deals']['view'] = 'none'; 173 | | $config['auth_override_class_method']['deals']['insert'] = 'digest'; 174 | | $config['auth_override_class_method']['accounts']['user'] = 'basic'; 175 | | $config['auth_override_class_method']['dashboard']['*'] = 'none|digest|basic'; 176 | | 177 | | Here 'deals', 'accounts' and 'dashboard' are controller names, 'view', 'insert' and 'user' are methods within. An asterisk may also be used to specify an authentication method for an entire classes methods. Ex: $config['auth_override_class_method']['dashboard']['*'] = 'basic'; (NOTE: leave off the '_get' or '_post' from the end of the method name) 178 | | Acceptable values are; 'none', 'digest' and 'basic'. 179 | | 180 | */ 181 | // $config['auth_override_class_method']['deals']['view'] = 'none'; 182 | // $config['auth_override_class_method']['deals']['insert'] = 'digest'; 183 | // $config['auth_override_class_method']['accounts']['user'] = 'basic'; 184 | // $config['auth_override_class_method']['dashboard']['*'] = 'basic'; 185 | 186 | 187 | // ---Uncomment list line for the wildard unit test 188 | // $config['auth_override_class_method']['wildcard_test_cases']['*'] = 'basic'; 189 | 190 | /* 191 | |-------------------------------------------------------------------------- 192 | | Override auth types for specific 'class/method/HTTP method' 193 | |-------------------------------------------------------------------------- 194 | | 195 | | example: 196 | | 197 | | $config['auth_override_class_method_http']['deals']['view']['get'] = 'none'; 198 | | $config['auth_override_class_method_http']['deals']['insert']['post'] = 'none'; 199 | | $config['auth_override_class_method_http']['deals']['*']['options'] = 'none'; 200 | */ 201 | 202 | // ---Uncomment list line for the wildard unit test 203 | // $config['auth_override_class_method_http']['wildcard_test_cases']['*']['options'] = 'basic'; 204 | 205 | /* 206 | |-------------------------------------------------------------------------- 207 | | REST Login Usernames 208 | |-------------------------------------------------------------------------- 209 | | 210 | | Array of usernames and passwords for login, if ldap is configured this is ignored 211 | | 212 | */ 213 | $config['rest_valid_logins'] = ['admin' => '1234']; 214 | 215 | /* 216 | |-------------------------------------------------------------------------- 217 | | Global IP White-listing 218 | |-------------------------------------------------------------------------- 219 | | 220 | | Limit connections to your REST server to White-listed IP addresses 221 | | 222 | | Usage: 223 | | 1. Set to TRUE and select an auth option for extreme security (client's IP 224 | | address must be in white-list and they must also log in) 225 | | 2. Set to TRUE with auth set to FALSE to allow White-listed IPs access with no login 226 | | 3. Set to FALSE but set 'auth_override_class_method' to 'white-list' to 227 | | restrict certain methods to IPs in your white-list 228 | | 229 | */ 230 | $config['rest_ip_whitelist_enabled'] = FALSE; 231 | 232 | /* 233 | |-------------------------------------------------------------------------- 234 | | REST Handle Exceptions 235 | |-------------------------------------------------------------------------- 236 | | 237 | | Handle exceptions caused by the controller 238 | | 239 | */ 240 | $config['rest_handle_exceptions'] = TRUE; 241 | 242 | /* 243 | |-------------------------------------------------------------------------- 244 | | REST IP White-list 245 | |-------------------------------------------------------------------------- 246 | | 247 | | Limit connections to your REST server with a comma separated 248 | | list of IP addresses 249 | | 250 | | e.g: '123.456.789.0, 987.654.32.1' 251 | | 252 | | 127.0.0.1 and 0.0.0.0 are allowed by default 253 | | 254 | */ 255 | $config['rest_ip_whitelist'] = ''; 256 | 257 | /* 258 | |-------------------------------------------------------------------------- 259 | | Global IP Blacklisting 260 | |-------------------------------------------------------------------------- 261 | | 262 | | Prevent connections to the REST server from blacklisted IP addresses 263 | | 264 | | Usage: 265 | | 1. Set to TRUE and add any IP address to 'rest_ip_blacklist' 266 | | 267 | */ 268 | $config['rest_ip_blacklist_enabled'] = FALSE; 269 | 270 | /* 271 | |-------------------------------------------------------------------------- 272 | | REST IP Blacklist 273 | |-------------------------------------------------------------------------- 274 | | 275 | | Prevent connections from the following IP addresses 276 | | 277 | | e.g: '123.456.789.0, 987.654.32.1' 278 | | 279 | */ 280 | $config['rest_ip_blacklist'] = ''; 281 | 282 | /* 283 | |-------------------------------------------------------------------------- 284 | | REST Database Group 285 | |-------------------------------------------------------------------------- 286 | | 287 | | Connect to a database group for keys, logging, etc. It will only connect 288 | | if you have any of these features enabled 289 | | 290 | */ 291 | $config['rest_database_group'] = 'default'; 292 | 293 | /* 294 | |-------------------------------------------------------------------------- 295 | | REST API Keys Table Name 296 | |-------------------------------------------------------------------------- 297 | | 298 | | The table name in your database that stores API keys 299 | | 300 | */ 301 | $config['rest_keys_table'] = 'keys'; 302 | 303 | /* 304 | |-------------------------------------------------------------------------- 305 | | REST Enable Keys 306 | |-------------------------------------------------------------------------- 307 | | 308 | | When set to TRUE, the REST API will look for a column name called 'key'. 309 | | If no key is provided, the request will result in an error. To override the 310 | | column name see 'rest_key_column' 311 | | 312 | | Default table schema: 313 | | CREATE TABLE `keys` ( 314 | | `id` INT(11) NOT NULL AUTO_INCREMENT, 315 | | `user_id` INT(11) NOT NULL, 316 | | `key` VARCHAR(40) NOT NULL, 317 | | `level` INT(2) NOT NULL, 318 | | `ignore_limits` TINYINT(1) NOT NULL DEFAULT '0', 319 | | `is_private_key` TINYINT(1) NOT NULL DEFAULT '0', 320 | | `ip_addresses` TEXT NULL DEFAULT NULL, 321 | | `date_created` INT(11) NOT NULL, 322 | | PRIMARY KEY (`id`) 323 | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 324 | | 325 | */ 326 | $config['rest_enable_keys'] = FALSE; 327 | 328 | /* 329 | |-------------------------------------------------------------------------- 330 | | REST Table Key Column Name 331 | |-------------------------------------------------------------------------- 332 | | 333 | | If not using the default table schema in 'rest_enable_keys', specify the 334 | | column name to match e.g. my_key 335 | | 336 | */ 337 | $config['rest_key_column'] = 'key'; 338 | 339 | /* 340 | |-------------------------------------------------------------------------- 341 | | REST API Limits method 342 | |-------------------------------------------------------------------------- 343 | | 344 | | Specify the method used to limit the API calls 345 | | 346 | | Available methods are : 347 | | $config['rest_limits_method'] = 'IP_ADDRESS'; // Put a limit per ip address 348 | | $config['rest_limits_method'] = 'API_KEY'; // Put a limit per api key 349 | | $config['rest_limits_method'] = 'METHOD_NAME'; // Put a limit on method calls 350 | | $config['rest_limits_method'] = 'ROUTED_URL'; // Put a limit on the routed URL 351 | | 352 | */ 353 | $config['rest_limits_method'] = 'ROUTED_URL'; 354 | 355 | /* 356 | |-------------------------------------------------------------------------- 357 | | REST Key Length 358 | |-------------------------------------------------------------------------- 359 | | 360 | | Length of the created keys. Check your default database schema on the 361 | | maximum length allowed 362 | | 363 | | Note: The maximum length is 40 364 | | 365 | */ 366 | $config['rest_key_length'] = 40; 367 | 368 | /* 369 | |-------------------------------------------------------------------------- 370 | | REST API Key Variable 371 | |-------------------------------------------------------------------------- 372 | | 373 | | Custom header to specify the API key 374 | 375 | | Note: Custom headers with the X- prefix are deprecated as of 376 | | 2012/06/12. See RFC 6648 specification for more details 377 | | 378 | */ 379 | $config['rest_key_name'] = 'X-API-KEY'; 380 | 381 | /* 382 | |-------------------------------------------------------------------------- 383 | | REST Enable Logging 384 | |-------------------------------------------------------------------------- 385 | | 386 | | When set to TRUE, the REST API will log actions based on the column names 'key', 'date', 387 | | 'time' and 'ip_address'. This is a general rule that can be overridden in the 388 | | $this->method array for each controller 389 | | 390 | | Default table schema: 391 | | CREATE TABLE `logs` ( 392 | | `id` INT(11) NOT NULL AUTO_INCREMENT, 393 | | `uri` VARCHAR(255) NOT NULL, 394 | | `method` VARCHAR(6) NOT NULL, 395 | | `params` TEXT DEFAULT NULL, 396 | | `api_key` VARCHAR(40) NOT NULL, 397 | | `ip_address` VARCHAR(45) NOT NULL, 398 | | `time` INT(11) NOT NULL, 399 | | `rtime` FLOAT DEFAULT NULL, 400 | | `authorized` VARCHAR(1) NOT NULL, 401 | | `response_code` smallint(3) DEFAULT '0', 402 | | PRIMARY KEY (`id`) 403 | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 404 | | 405 | */ 406 | $config['rest_enable_logging'] = FALSE; 407 | 408 | /* 409 | |-------------------------------------------------------------------------- 410 | | REST API Logs Table Name 411 | |-------------------------------------------------------------------------- 412 | | 413 | | If not using the default table schema in 'rest_enable_logging', specify the 414 | | table name to match e.g. my_logs 415 | | 416 | */ 417 | $config['rest_logs_table'] = 'logs'; 418 | 419 | /* 420 | |-------------------------------------------------------------------------- 421 | | REST Method Access Control 422 | |-------------------------------------------------------------------------- 423 | | When set to TRUE, the REST API will check the access table to see if 424 | | the API key can access that controller. 'rest_enable_keys' must be enabled 425 | | to use this 426 | | 427 | | Default table schema: 428 | | CREATE TABLE `access` ( 429 | | `id` INT(11) unsigned NOT NULL AUTO_INCREMENT, 430 | | `key` VARCHAR(40) NOT NULL DEFAULT '', 431 | | `all_access` TINYINT(1) NOT NULL DEFAULT '0', 432 | | `controller` VARCHAR(50) NOT NULL DEFAULT '', 433 | | `date_created` DATETIME DEFAULT NULL, 434 | | `date_modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 435 | | PRIMARY KEY (`id`) 436 | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 437 | | 438 | */ 439 | $config['rest_enable_access'] = FALSE; 440 | 441 | /* 442 | |-------------------------------------------------------------------------- 443 | | REST API Access Table Name 444 | |-------------------------------------------------------------------------- 445 | | 446 | | If not using the default table schema in 'rest_enable_access', specify the 447 | | table name to match e.g. my_access 448 | | 449 | */ 450 | $config['rest_access_table'] = 'access'; 451 | 452 | /* 453 | |-------------------------------------------------------------------------- 454 | | REST API Param Log Format 455 | |-------------------------------------------------------------------------- 456 | | 457 | | When set to TRUE, the REST API log parameters will be stored in the database as JSON 458 | | Set to FALSE to log as serialized PHP 459 | | 460 | */ 461 | $config['rest_logs_json_params'] = FALSE; 462 | 463 | /* 464 | |-------------------------------------------------------------------------- 465 | | REST Enable Limits 466 | |-------------------------------------------------------------------------- 467 | | 468 | | When set to TRUE, the REST API will count the number of uses of each method 469 | | by an API key each hour. This is a general rule that can be overridden in the 470 | | $this->method array in each controller 471 | | 472 | | Default table schema: 473 | | CREATE TABLE `limits` ( 474 | | `id` INT(11) NOT NULL AUTO_INCREMENT, 475 | | `uri` VARCHAR(255) NOT NULL, 476 | | `count` INT(10) NOT NULL, 477 | | `hour_started` INT(11) NOT NULL, 478 | | `api_key` VARCHAR(40) NOT NULL, 479 | | PRIMARY KEY (`id`) 480 | | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 481 | | 482 | | To specify the limits within the controller's __construct() method, add per-method 483 | | limits with: 484 | | 485 | | $this->method['METHOD_NAME']['limit'] = [NUM_REQUESTS_PER_HOUR]; 486 | | 487 | | See application/controllers/api/example.php for examples 488 | */ 489 | $config['rest_enable_limits'] = FALSE; 490 | 491 | /* 492 | |-------------------------------------------------------------------------- 493 | | REST API Limits Table Name 494 | |-------------------------------------------------------------------------- 495 | | 496 | | If not using the default table schema in 'rest_enable_limits', specify the 497 | | table name to match e.g. my_limits 498 | | 499 | */ 500 | $config['rest_limits_table'] = 'limits'; 501 | 502 | /* 503 | |-------------------------------------------------------------------------- 504 | | REST Ignore HTTP Accept 505 | |-------------------------------------------------------------------------- 506 | | 507 | | Set to TRUE to ignore the HTTP Accept and speed up each request a little. 508 | | Only do this if you are using the $this->rest_format or /format/xml in URLs 509 | | 510 | */ 511 | $config['rest_ignore_http_accept'] = FALSE; 512 | 513 | /* 514 | |-------------------------------------------------------------------------- 515 | | REST AJAX Only 516 | |-------------------------------------------------------------------------- 517 | | 518 | | Set to TRUE to allow AJAX requests only. Set to FALSE to accept HTTP requests 519 | | 520 | | Note: If set to TRUE and the request is not AJAX, a 505 response with the 521 | | error message 'Only AJAX requests are accepted.' will be returned. 522 | | 523 | | Hint: This is good for production environments 524 | | 525 | */ 526 | $config['rest_ajax_only'] = FALSE; 527 | 528 | /* 529 | |-------------------------------------------------------------------------- 530 | | REST Language File 531 | |-------------------------------------------------------------------------- 532 | | 533 | | Language file to load from the language directory 534 | | 535 | */ 536 | $config['rest_language'] = 'english'; 537 | 538 | /* 539 | |-------------------------------------------------------------------------- 540 | | CORS Check 541 | |-------------------------------------------------------------------------- 542 | | 543 | | Set to TRUE to enable Cross-Origin Resource Sharing (CORS). Useful if you 544 | | are hosting your API on a different domain from the application that 545 | | will access it through a browser 546 | | 547 | */ 548 | $config['check_cors'] = FALSE; 549 | 550 | /* 551 | |-------------------------------------------------------------------------- 552 | | CORS Allowable Headers 553 | |-------------------------------------------------------------------------- 554 | | 555 | | If using CORS checks, set the allowable headers here 556 | | 557 | */ 558 | $config['allowed_cors_headers'] = [ 559 | 'Origin', 560 | 'X-Requested-With', 561 | 'Content-Type', 562 | 'Accept', 563 | 'Access-Control-Request-Method' 564 | ]; 565 | 566 | /* 567 | |-------------------------------------------------------------------------- 568 | | CORS Allowable Methods 569 | |-------------------------------------------------------------------------- 570 | | 571 | | If using CORS checks, you can set the methods you want to be allowed 572 | | 573 | */ 574 | $config['allowed_cors_methods'] = [ 575 | 'GET', 576 | 'POST', 577 | 'OPTIONS', 578 | 'PUT', 579 | 'PATCH', 580 | 'DELETE' 581 | ]; 582 | 583 | /* 584 | |-------------------------------------------------------------------------- 585 | | CORS Allow Any Domain 586 | |-------------------------------------------------------------------------- 587 | | 588 | | Set to TRUE to enable Cross-Origin Resource Sharing (CORS) from any 589 | | source domain 590 | | 591 | */ 592 | $config['allow_any_cors_domain'] = FALSE; 593 | 594 | /* 595 | |-------------------------------------------------------------------------- 596 | | CORS Allowable Domains 597 | |-------------------------------------------------------------------------- 598 | | 599 | | Used if $config['check_cors'] is set to TRUE and $config['allow_any_cors_domain'] 600 | | is set to FALSE. Set all the allowable domains within the array 601 | | 602 | | e.g. $config['allowed_origins'] = ['http://www.example.com', 'https://spa.example.com'] 603 | | 604 | */ 605 | $config['allowed_cors_origins'] = []; 606 | -------------------------------------------------------------------------------- /application/config/routes.php: -------------------------------------------------------------------------------- 1 | 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; 55 | 56 | // User API Routes 57 | $route['api/user/register'] = 'api/users/register'; 58 | $route['api/user/login'] = 'api/users/login'; 59 | 60 | // Users Article Routes 61 | $route['api/article/create'] = 'api/articles/createArticle'; 62 | 63 | // Deleta an Article Routes 64 | # https://codeigniter.com/user_guide/general/routing.html#using-http-verbs-in-routes 65 | $route['api/article/(:num)/delete']["DELETE"] = 'api/articles/deleteArticle/$1'; 66 | 67 | // Update and Article Route :: PUT API Request 68 | $route['api/article/update']["put"] = 'api/articles/updateArticle'; -------------------------------------------------------------------------------- /application/config/smileys.php: -------------------------------------------------------------------------------- 1 | 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 | ); 65 | -------------------------------------------------------------------------------- /application/config/user_agents.php: -------------------------------------------------------------------------------- 1 | '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' => 'Spartan', 65 | 'Chrome' => 'Chrome', 66 | // Opera 10+ always reports Opera/9.80 and appends 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 | 'palm' => 'Palm', 114 | 'iphone' => 'Apple iPhone', 115 | 'ipad' => 'iPad', 116 | 'ipod' => 'Apple iPod Touch', 117 | 'sony' => 'Sony Ericsson', 118 | 'ericsson' => 'Sony Ericsson', 119 | 'blackberry' => 'BlackBerry', 120 | 'cocoon' => 'O2 Cocoon', 121 | 'blazer' => 'Treo', 122 | 'lg' => 'LG', 123 | 'amoi' => 'Amoi', 124 | 'xda' => 'XDA', 125 | 'mda' => 'MDA', 126 | 'vario' => 'Vario', 127 | 'htc' => 'HTC', 128 | 'samsung' => 'Samsung', 129 | 'sharp' => 'Sharp', 130 | 'sie-' => 'Siemens', 131 | 'alcatel' => 'Alcatel', 132 | 'benq' => 'BenQ', 133 | 'ipaq' => 'HP iPaq', 134 | 'mot-' => 'Motorola', 135 | 'playstation portable' => 'PlayStation Portable', 136 | 'playstation 3' => 'PlayStation 3', 137 | 'playstation vita' => 'PlayStation Vita', 138 | 'hiptop' => 'Danger Hiptop', 139 | 'nec-' => 'NEC', 140 | 'panasonic' => 'Panasonic', 141 | 'philips' => 'Philips', 142 | 'sagem' => 'Sagem', 143 | 'sanyo' => 'Sanyo', 144 | 'spv' => 'SPV', 145 | 'zte' => 'ZTE', 146 | 'sendo' => 'Sendo', 147 | 'nintendo dsi' => 'Nintendo DSi', 148 | 'nintendo ds' => 'Nintendo DS', 149 | 'nintendo 3ds' => 'Nintendo 3DS', 150 | 'wii' => 'Nintendo Wii', 151 | 'open web' => 'Open Web', 152 | 'openweb' => 'OpenWeb', 153 | 154 | // Operating Systems 155 | 'android' => 'Android', 156 | 'symbian' => 'Symbian', 157 | 'SymbianOS' => 'SymbianOS', 158 | 'elaine' => 'Palm', 159 | 'series60' => 'Symbian S60', 160 | 'windows ce' => 'Windows CE', 161 | 162 | // Browsers 163 | 'obigo' => 'Obigo', 164 | 'netfront' => 'Netfront Browser', 165 | 'openwave' => 'Openwave Browser', 166 | 'mobilexplorer' => 'Mobile Explorer', 167 | 'operamini' => 'Opera Mini', 168 | 'opera mini' => 'Opera Mini', 169 | 'opera mobi' => 'Opera Mobile', 170 | 'fennec' => 'Firefox Mobile', 171 | 172 | // Other 173 | 'digital paths' => 'Digital Paths', 174 | 'avantgo' => 'AvantGo', 175 | 'xiino' => 'Xiino', 176 | 'novarra' => 'Novarra Transcoder', 177 | 'vodafone' => 'Vodafone', 178 | 'docomo' => 'NTT DoCoMo', 179 | 'o2' => 'O2', 180 | 181 | // Fallback 182 | 'mobile' => 'Generic Mobile', 183 | 'wireless' => 'Generic Mobile', 184 | 'j2me' => 'Generic Mobile', 185 | 'midp' => 'Generic Mobile', 186 | 'cldc' => 'Generic Mobile', 187 | 'up.link' => 'Generic Mobile', 188 | 'up.browser' => 'Generic Mobile', 189 | 'smartphone' => 'Generic Mobile', 190 | 'cellphone' => 'Generic Mobile' 191 | ); 192 | 193 | // There are hundreds of bots but these are the most common. 194 | $robots = array( 195 | 'googlebot' => 'Googlebot', 196 | 'msnbot' => 'MSNBot', 197 | 'baiduspider' => 'Baiduspider', 198 | 'bingbot' => 'Bing', 199 | 'slurp' => 'Inktomi Slurp', 200 | 'yahoo' => 'Yahoo', 201 | 'ask jeeves' => 'Ask Jeeves', 202 | 'fastcrawler' => 'FastCrawler', 203 | 'infoseek' => 'InfoSeek Robot 1.0', 204 | 'lycos' => 'Lycos', 205 | 'yandex' => 'YandexBot', 206 | 'mediapartners-google' => 'MediaPartners Google', 207 | 'CRAZYWEBCRAWLER' => 'Crazy Webcrawler', 208 | 'adsbot-google' => 'AdsBot Google', 209 | 'feedfetcher-google' => 'Feedfetcher Google', 210 | 'curious george' => 'Curious George', 211 | 'ia_archiver' => 'Alexa Crawler', 212 | 'MJ12bot' => 'Majestic-12', 213 | 'Uptimebot' => 'Uptimebot' 214 | ); 215 | -------------------------------------------------------------------------------- /application/controllers/Welcome.php: -------------------------------------------------------------------------------- 1 | 19 | * @see https://codeigniter.com/user_guide/general/urls.html 20 | */ 21 | public function index() 22 | { 23 | $this->load->view('welcome_message'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /application/controllers/api/Articles.php: -------------------------------------------------------------------------------- 1 | load->library('Authorization_Token'); 24 | 25 | /** 26 | * User Token Validation 27 | */ 28 | $is_valid_token = $this->authorization_token->validateToken(); 29 | if (!empty($is_valid_token) AND $is_valid_token['status'] === TRUE) 30 | { 31 | # Create a User Article 32 | 33 | # XSS Filtering (https://www.codeigniter.com/user_guide/libraries/security.html) 34 | $_POST = $this->security->xss_clean($_POST); 35 | 36 | # Form Validation 37 | $this->form_validation->set_rules('title', 'Title', 'trim|required|max_length[50]'); 38 | $this->form_validation->set_rules('description', 'Description', 'trim|required|max_length[200]'); 39 | if ($this->form_validation->run() == FALSE) 40 | { 41 | // Form Validation Errors 42 | $message = array( 43 | 'status' => false, 44 | 'error' => $this->form_validation->error_array(), 45 | 'message' => validation_errors() 46 | ); 47 | 48 | $this->response($message, REST_Controller::HTTP_NOT_FOUND); 49 | } 50 | else 51 | { 52 | // Load Article Model 53 | $this->load->model('article_model', 'ArticleModel'); 54 | 55 | $insert_data = [ 56 | 'user_id' => $is_valid_token['data']->id, 57 | 'title' => $this->input->post('title', TRUE), 58 | 'description' => $this->input->post('description', TRUE), 59 | 'created_at' => time(), 60 | 'updated_at' => time(), 61 | ]; 62 | 63 | // Insert Article 64 | $output = $this->ArticleModel->create_article($insert_data); 65 | 66 | if ($output > 0 AND !empty($output)) 67 | { 68 | // Success 69 | $message = [ 70 | 'status' => true, 71 | 'message' => "Article Add" 72 | ]; 73 | $this->response($message, REST_Controller::HTTP_OK); 74 | } else 75 | { 76 | // Error 77 | $message = [ 78 | 'status' => FALSE, 79 | 'message' => "Article not create" 80 | ]; 81 | $this->response($message, REST_Controller::HTTP_NOT_FOUND); 82 | } 83 | } 84 | 85 | } else { 86 | $this->response(['status' => FALSE, 'message' => $is_valid_token['message'] ], REST_Controller::HTTP_NOT_FOUND); 87 | } 88 | } 89 | 90 | /** 91 | * Delete an Article with API 92 | * @method: DELETE 93 | */ 94 | public function deleteArticle_delete($id) 95 | { 96 | header("Access-Control-Allow-Origin: *"); 97 | 98 | // Load Authorization Token Library 99 | $this->load->library('Authorization_Token'); 100 | 101 | /** 102 | * User Token Validation 103 | */ 104 | $is_valid_token = $this->authorization_token->validateToken(); 105 | if (!empty($is_valid_token) AND $is_valid_token['status'] === TRUE) 106 | { 107 | # Delete a User Article 108 | 109 | # XSS Filtering (https://www.codeigniter.com/user_guide/libraries/security.html) 110 | $id = $this->security->xss_clean($id); 111 | 112 | if (empty($id) AND !is_numeric($id)) 113 | { 114 | $this->response(['status' => FALSE, 'message' => 'Invalid Article ID' ], REST_Controller::HTTP_NOT_FOUND); 115 | } 116 | else 117 | { 118 | // Load Article Model 119 | $this->load->model('article_model', 'ArticleModel'); 120 | 121 | $delete_article = [ 122 | 'id' => $id, 123 | 'user_id' => $is_valid_token['data']->id, 124 | ]; 125 | 126 | // Delete an Article 127 | $output = $this->ArticleModel->delete_article($delete_article); 128 | 129 | if ($output > 0 AND !empty($output)) 130 | { 131 | // Success 132 | $message = [ 133 | 'status' => true, 134 | 'message' => "Article Deleted" 135 | ]; 136 | $this->response($message, REST_Controller::HTTP_OK); 137 | } else 138 | { 139 | // Error 140 | $message = [ 141 | 'status' => FALSE, 142 | 'message' => "Article not delete" 143 | ]; 144 | $this->response($message, REST_Controller::HTTP_NOT_FOUND); 145 | } 146 | } 147 | 148 | } else { 149 | $this->response(['status' => FALSE, 'message' => $is_valid_token['message'] ], REST_Controller::HTTP_NOT_FOUND); 150 | } 151 | } 152 | 153 | /** 154 | * Update an Article with API 155 | * @method: PUT 156 | */ 157 | public function updateArticle_put() 158 | { 159 | header("Access-Control-Allow-Origin: *"); 160 | 161 | // Load Authorization Token Library 162 | $this->load->library('Authorization_Token'); 163 | 164 | /** 165 | * User Token Validation 166 | */ 167 | $is_valid_token = $this->authorization_token->validateToken(); 168 | if (!empty($is_valid_token) AND $is_valid_token['status'] === TRUE) 169 | { 170 | # Update a User Article 171 | 172 | 173 | # XSS Filtering (https://www.codeigniter.com/user_guide/libraries/security.html) 174 | $_POST = json_decode($this->security->xss_clean(file_get_contents("php://input")), true); 175 | 176 | $this->form_validation->set_data([ 177 | 'id' => $this->input->post('id', TRUE), 178 | 'title' => $this->input->post('title', TRUE), 179 | 'description' => $this->input->post('description', TRUE), 180 | ]); 181 | 182 | # Form Validation 183 | $this->form_validation->set_rules('id', 'Article ID', 'trim|required|numeric'); 184 | $this->form_validation->set_rules('title', 'Title', 'trim|required|max_length[50]'); 185 | $this->form_validation->set_rules('description', 'Description', 'trim|required|max_length[200]'); 186 | if ($this->form_validation->run() == FALSE) 187 | { 188 | // Form Validation Errors 189 | $message = array( 190 | 'status' => false, 191 | 'error' => $this->form_validation->error_array(), 192 | 'message' => validation_errors() 193 | ); 194 | 195 | $this->response($message, REST_Controller::HTTP_NOT_FOUND); 196 | } 197 | else 198 | { 199 | // Load Article Model 200 | $this->load->model('article_model', 'ArticleModel'); 201 | 202 | $update_data = [ 203 | 'user_id' => $is_valid_token['data']->id, 204 | 'id' => $this->input->post('id', TRUE), 205 | 'title' => $this->input->post('title', TRUE), 206 | 'description' => $this->input->post('description', TRUE), 207 | ]; 208 | 209 | // Update an Article 210 | $output = $this->ArticleModel->update_article($update_data); 211 | 212 | if ($output > 0 AND !empty($output)) 213 | { 214 | // Success 215 | $message = [ 216 | 'status' => true, 217 | 'message' => "Article Updated" 218 | ]; 219 | $this->response($message, REST_Controller::HTTP_OK); 220 | } else 221 | { 222 | // Error 223 | $message = [ 224 | 'status' => FALSE, 225 | 'message' => "Article not update" 226 | ]; 227 | $this->response($message, REST_Controller::HTTP_NOT_FOUND); 228 | } 229 | } 230 | 231 | } else { 232 | $this->response(['status' => FALSE, 'message' => $is_valid_token['message'] ], REST_Controller::HTTP_NOT_FOUND); 233 | } 234 | } 235 | } -------------------------------------------------------------------------------- /application/controllers/api/Users.php: -------------------------------------------------------------------------------- 1 | load->model('user_model', 'UserModel'); 13 | } 14 | 15 | /** 16 | * User Register 17 | * -------------------------- 18 | * @param: fullname 19 | * @param: username 20 | * @param: email 21 | * @param: password 22 | * -------------------------- 23 | * @method : POST 24 | * @link : api/user/register 25 | */ 26 | public function register_post() 27 | { 28 | header("Access-Control-Allow-Origin: *"); 29 | 30 | # XSS Filtering (https://www.codeigniter.com/user_guide/libraries/security.html) 31 | $_POST = $this->security->xss_clean($_POST); 32 | 33 | # Form Validation 34 | $this->form_validation->set_rules('fullname', 'Full Name', 'trim|required|max_length[50]'); 35 | $this->form_validation->set_rules('username', 'Username', 'trim|required|is_unique[users.username]|alpha_numeric|max_length[20]', 36 | array('is_unique' => 'This %s already exists please enter another username') 37 | ); 38 | $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|max_length[80]|is_unique[users.email]', 39 | array('is_unique' => 'This %s already exists please enter another email address') 40 | ); 41 | $this->form_validation->set_rules('password', 'Password', 'trim|required|max_length[100]'); 42 | if ($this->form_validation->run() == FALSE) 43 | { 44 | // Form Validation Errors 45 | $message = array( 46 | 'status' => false, 47 | 'error' => $this->form_validation->error_array(), 48 | 'message' => validation_errors() 49 | ); 50 | 51 | $this->response($message, REST_Controller::HTTP_NOT_FOUND); 52 | } 53 | else 54 | { 55 | $insert_data = [ 56 | 'full_name' => $this->input->post('fullname', TRUE), 57 | 'email' => $this->input->post('email', TRUE), 58 | 'username' => $this->input->post('username', TRUE), 59 | 'password' => md5($this->input->post('password', TRUE)), 60 | 'created_at' => time(), 61 | 'updated_at' => time(), 62 | ]; 63 | 64 | // Insert User in Database 65 | $output = $this->UserModel->insert_user($insert_data); 66 | if ($output > 0 AND !empty($output)) 67 | { 68 | // Success 200 Code Send 69 | $message = [ 70 | 'status' => true, 71 | 'message' => "User registration successful" 72 | ]; 73 | $this->response($message, REST_Controller::HTTP_OK); 74 | } else 75 | { 76 | // Error 77 | $message = [ 78 | 'status' => FALSE, 79 | 'message' => "Not Register Your Account." 80 | ]; 81 | $this->response($message, REST_Controller::HTTP_NOT_FOUND); 82 | } 83 | } 84 | } 85 | 86 | 87 | /** 88 | * User Login API 89 | * -------------------- 90 | * @param: username or email 91 | * @param: password 92 | * -------------------------- 93 | * @method : POST 94 | * @link: api/user/login 95 | */ 96 | public function login_post() 97 | { 98 | header("Access-Control-Allow-Origin: *"); 99 | 100 | # XSS Filtering (https://www.codeigniter.com/user_guide/libraries/security.html) 101 | $_POST = $this->security->xss_clean($_POST); 102 | 103 | # Form Validation 104 | $this->form_validation->set_rules('username', 'Username', 'trim|required'); 105 | $this->form_validation->set_rules('password', 'Password', 'trim|required|max_length[100]'); 106 | if ($this->form_validation->run() == FALSE) 107 | { 108 | // Form Validation Errors 109 | $message = array( 110 | 'status' => false, 111 | 'error' => $this->form_validation->error_array(), 112 | 'message' => validation_errors() 113 | ); 114 | 115 | $this->response($message, REST_Controller::HTTP_NOT_FOUND); 116 | } 117 | else 118 | { 119 | // Load Login Function 120 | $output = $this->UserModel->user_login($this->input->post('username'), $this->input->post('password')); 121 | if (!empty($output) AND $output != FALSE) 122 | { 123 | // Load Authorization Token Library 124 | $this->load->library('Authorization_Token'); 125 | 126 | // Generate Token 127 | $token_data['id'] = $output->id; 128 | $token_data['full_name'] = $output->full_name; 129 | $token_data['username'] = $output->username; 130 | $token_data['email'] = $output->email; 131 | $token_data['created_at'] = $output->created_at; 132 | $token_data['updated_at'] = $output->updated_at; 133 | $token_data['time'] = time(); 134 | 135 | $user_token = $this->authorization_token->generateToken($token_data); 136 | 137 | $return_data = [ 138 | 'user_id' => $output->id, 139 | 'full_name' => $output->full_name, 140 | 'email' => $output->email, 141 | 'created_at' => $output->created_at, 142 | 'token' => $user_token, 143 | ]; 144 | 145 | // Login Success 146 | $message = [ 147 | 'status' => true, 148 | 'data' => $return_data, 149 | 'message' => "User login successful" 150 | ]; 151 | $this->response($message, REST_Controller::HTTP_OK); 152 | } else 153 | { 154 | // Login Error 155 | $message = [ 156 | 'status' => FALSE, 157 | 'message' => "Invalid Username or Password" 158 | ]; 159 | $this->response($message, REST_Controller::HTTP_NOT_FOUND); 160 | } 161 | } 162 | } 163 | } -------------------------------------------------------------------------------- /application/controllers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/core/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/helpers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/hooks/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/bulgarian/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/bulgarian/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/dutch/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/english/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/french/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/german/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/indonesia/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/indonesia/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/italian/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/portuguese-brazilian/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/romanian/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/serbian_cyr/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/serbian_lat/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/simplified-chinese/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/spanish/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/traditional-chinese/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/turkish/rest_controller_lang.php: -------------------------------------------------------------------------------- 1 | CI =& get_instance(); 48 | 49 | /** 50 | * jwt config file load 51 | */ 52 | $this->CI->load->config('jwt'); 53 | 54 | /** 55 | * Load Config Items Values 56 | */ 57 | $this->token_key = $this->CI->config->item('jwt_key'); 58 | $this->token_algorithm = $this->CI->config->item('jwt_algorithm'); 59 | } 60 | 61 | /** 62 | * Generate Token 63 | * @param: user data 64 | */ 65 | public function generateToken($data) 66 | { 67 | try { 68 | return JWT::encode($data, $this->token_key, $this->token_algorithm); 69 | } 70 | catch(Exception $e) { 71 | return 'Message: ' .$e->getMessage(); 72 | } 73 | } 74 | 75 | /** 76 | * Validate Token with Header 77 | * @return : user informations 78 | */ 79 | public function validateToken() 80 | { 81 | /** 82 | * Request All Headers 83 | */ 84 | $headers = $this->CI->input->request_headers(); 85 | 86 | /** 87 | * Authorization Header Exists 88 | */ 89 | $token_data = $this->tokenIsExist($headers); 90 | if($token_data['status'] === TRUE) 91 | { 92 | try 93 | { 94 | /** 95 | * Token Decode 96 | */ 97 | try { 98 | $token_decode = JWT::decode($headers[$token_data['key']], $this->token_key, array($this->token_algorithm)); 99 | } 100 | catch(Exception $e) { 101 | return ['status' => FALSE, 'message' => $e->getMessage()]; 102 | } 103 | 104 | if(!empty($token_decode) AND is_object($token_decode)) 105 | { 106 | // Check User ID (exists and numeric) 107 | if(empty($token_decode->id) OR !is_numeric($token_decode->id)) 108 | { 109 | return ['status' => FALSE, 'message' => 'User ID Not Define!']; 110 | 111 | // Check Token Time 112 | }else if(empty($token_decode->time OR !is_numeric($token_decode->time))) { 113 | 114 | return ['status' => FALSE, 'message' => 'Token Time Not Define!']; 115 | } 116 | else 117 | { 118 | /** 119 | * Check Token Time Valid 120 | */ 121 | $time_difference = strtotime('now') - $token_decode->time; 122 | if( $time_difference >= $this->token_expire_time ) 123 | { 124 | return ['status' => FALSE, 'message' => 'Token Time Expire.']; 125 | 126 | }else 127 | { 128 | /** 129 | * All Validation False Return Data 130 | */ 131 | return ['status' => TRUE, 'data' => $token_decode]; 132 | } 133 | } 134 | 135 | }else{ 136 | return ['status' => FALSE, 'message' => 'Forbidden']; 137 | } 138 | } 139 | catch(Exception $e) { 140 | return ['status' => FALSE, 'message' => $e->getMessage()]; 141 | } 142 | }else 143 | { 144 | // Authorization Header Not Found! 145 | return ['status' => FALSE, 'message' => $token_data['message'] ]; 146 | } 147 | } 148 | 149 | /** 150 | * Validate Token with POST Request 151 | */ 152 | public function validateTokenPost() 153 | { 154 | if(isset($_POST['token'])) 155 | { 156 | $token = $this->CI->input->post('token', TRUE); 157 | if(!empty($token) AND is_string($token) AND !is_array($token)) 158 | { 159 | try 160 | { 161 | /** 162 | * Token Decode 163 | */ 164 | try { 165 | $token_decode = JWT::decode($token, $this->token_key, array($this->token_algorithm)); 166 | } 167 | catch(Exception $e) { 168 | return ['status' => FALSE, 'message' => $e->getMessage()]; 169 | } 170 | 171 | if(!empty($token_decode) AND is_object($token_decode)) 172 | { 173 | // Check User ID (exists and numeric) 174 | if(empty($token_decode->id) OR !is_numeric($token_decode->id)) 175 | { 176 | return ['status' => FALSE, 'message' => 'User ID Not Define!']; 177 | 178 | // Check Token Time 179 | }else if(empty($token_decode->time OR !is_numeric($token_decode->time))) { 180 | 181 | return ['status' => FALSE, 'message' => 'Token Time Not Define!']; 182 | } 183 | else 184 | { 185 | /** 186 | * Check Token Time Valid 187 | */ 188 | $time_difference = strtotime('now') - $token_decode->time; 189 | if( $time_difference >= $this->token_expire_time ) 190 | { 191 | return ['status' => FALSE, 'message' => 'Token Time Expire.']; 192 | 193 | }else 194 | { 195 | /** 196 | * All Validation False Return Data 197 | */ 198 | return ['status' => TRUE, 'data' => $token_decode]; 199 | } 200 | } 201 | 202 | }else{ 203 | return ['status' => FALSE, 'message' => 'Forbidden']; 204 | } 205 | } 206 | catch(Exception $e) { 207 | return ['status' => FALSE, 'message' => $e->getMessage()]; 208 | } 209 | }else 210 | { 211 | return ['status' => FALSE, 'message' => 'Token is not defined.' ]; 212 | } 213 | } else { 214 | return ['status' => FALSE, 'message' => 'Token is not defined.']; 215 | } 216 | } 217 | 218 | /** 219 | * Token Header Check 220 | * @param: request headers 221 | */ 222 | public function tokenIsExist($headers) 223 | { 224 | if(!empty($headers) AND is_array($headers)) { 225 | foreach ($this->token_header as $key) { 226 | if (array_key_exists($key, $headers) AND !empty($key)) 227 | return ['status' => TRUE, 'key' => $key]; 228 | } 229 | } 230 | return ['status' => FALSE, 'message' => 'Token is not defined.']; 231 | } 232 | 233 | /** 234 | * Fetch User Data 235 | * ----------------- 236 | * @param: token 237 | * @return: user_data 238 | */ 239 | public function userData() 240 | { 241 | /** 242 | * Request All Headers 243 | */ 244 | $headers = $this->CI->input->request_headers(); 245 | 246 | /** 247 | * Authorization Header Exists 248 | */ 249 | $token_data = $this->tokenIsExist($headers); 250 | if($token_data['status'] === TRUE) 251 | { 252 | try 253 | { 254 | /** 255 | * Token Decode 256 | */ 257 | try { 258 | $token_decode = JWT::decode($headers[$token_data['key']], $this->token_key, array($this->token_algorithm)); 259 | } 260 | catch(Exception $e) { 261 | return ['status' => FALSE, 'message' => $e->getMessage()]; 262 | } 263 | 264 | if(!empty($token_decode) AND is_object($token_decode)) 265 | { 266 | return $token_decode; 267 | }else{ 268 | return ['status' => FALSE, 'message' => 'Forbidden']; 269 | } 270 | } 271 | catch(Exception $e) { 272 | return ['status' => FALSE, 'message' => $e->getMessage()]; 273 | } 274 | }else 275 | { 276 | // Authorization Header Not Found! 277 | return ['status' => FALSE, 'message' => $token_data['message'] ]; 278 | } 279 | } 280 | } -------------------------------------------------------------------------------- /application/libraries/Format.php: -------------------------------------------------------------------------------- 1 | _CI = &get_instance(); 89 | 90 | // Load the inflector helper 91 | $this->_CI->load->helper('inflector'); 92 | 93 | // If the provided data is already formatted we should probably convert it to an array 94 | if ($from_type !== NULL) 95 | { 96 | if (method_exists($this, '_from_'.$from_type)) 97 | { 98 | $data = call_user_func([$this, '_from_'.$from_type], $data); 99 | } 100 | else 101 | { 102 | throw new Exception('Format class does not support conversion from "'.$from_type.'".'); 103 | } 104 | } 105 | 106 | // Set the member variable to the data passed 107 | $this->_data = $data; 108 | } 109 | 110 | /** 111 | * Create an instance of the format class 112 | * e.g: echo $this->format->factory(['foo' => 'bar'])->to_csv(); 113 | * 114 | * @param mixed $data Data to convert/parse 115 | * @param string $from_type Type to convert from e.g. json, csv, html 116 | * 117 | * @return object Instance of the format class 118 | */ 119 | public function factory($data, $from_type = NULL) 120 | { 121 | // $class = __CLASS__; 122 | // return new $class(); 123 | 124 | return new static($data, $from_type); 125 | } 126 | 127 | // FORMATTING OUTPUT --------------------------------------------------------- 128 | 129 | /** 130 | * Format data as an array 131 | * 132 | * @param mixed|NULL $data Optional data to pass, so as to override the data passed 133 | * to the constructor 134 | * @return array Data parsed as an array; otherwise, an empty array 135 | */ 136 | public function to_array($data = NULL) 137 | { 138 | // If no data is passed as a parameter, then use the data passed 139 | // via the constructor 140 | if ($data === NULL && func_num_args() === 0) 141 | { 142 | $data = $this->_data; 143 | } 144 | 145 | // Cast as an array if not already 146 | if (is_array($data) === FALSE) 147 | { 148 | $data = (array) $data; 149 | } 150 | 151 | $array = []; 152 | foreach ((array) $data as $key => $value) 153 | { 154 | if (is_object($value) === TRUE || is_array($value) === TRUE) 155 | { 156 | $array[$key] = $this->to_array($value); 157 | } 158 | else 159 | { 160 | $array[$key] = $value; 161 | } 162 | } 163 | 164 | return $array; 165 | } 166 | 167 | /** 168 | * Format data as XML 169 | * 170 | * @param mixed|NULL $data Optional data to pass, so as to override the data passed 171 | * to the constructor 172 | * @param NULL $structure 173 | * @param string $basenode 174 | * @return mixed 175 | */ 176 | public function to_xml($data = NULL, $structure = NULL, $basenode = 'xml') 177 | { 178 | if ($data === NULL && func_num_args() === 0) 179 | { 180 | $data = $this->_data; 181 | } 182 | 183 | if ($structure === NULL) 184 | { 185 | $structure = simplexml_load_string("<$basenode />"); 186 | } 187 | 188 | // Force it to be something useful 189 | if (is_array($data) === FALSE && is_object($data) === FALSE) 190 | { 191 | $data = (array) $data; 192 | } 193 | 194 | foreach ($data as $key => $value) 195 | { 196 | 197 | //change false/true to 0/1 198 | if (is_bool($value)) 199 | { 200 | $value = (int) $value; 201 | } 202 | 203 | // no numeric keys in our xml please! 204 | if (is_numeric($key)) 205 | { 206 | // make string key... 207 | $key = (singular($basenode) != $basenode) ? singular($basenode) : 'item'; 208 | } 209 | 210 | // replace anything not alpha numeric 211 | $key = preg_replace('/[^a-z_\-0-9]/i', '', $key); 212 | 213 | if ($key === '_attributes' && (is_array($value) || is_object($value))) 214 | { 215 | $attributes = $value; 216 | if (is_object($attributes)) 217 | { 218 | $attributes = get_object_vars($attributes); 219 | } 220 | 221 | foreach ($attributes as $attribute_name => $attribute_value) 222 | { 223 | $structure->addAttribute($attribute_name, $attribute_value); 224 | } 225 | } 226 | // if there is another array found recursively call this function 227 | elseif (is_array($value) || is_object($value)) 228 | { 229 | $node = $structure->addChild($key); 230 | 231 | // recursive call. 232 | $this->to_xml($value, $node, $key); 233 | } 234 | else 235 | { 236 | // add single node. 237 | $value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8'); 238 | 239 | $structure->addChild($key, $value); 240 | } 241 | } 242 | 243 | return $structure->asXML(); 244 | } 245 | 246 | /** 247 | * Format data as HTML 248 | * 249 | * @param mixed|NULL $data Optional data to pass, so as to override the data passed 250 | * to the constructor 251 | * @return mixed 252 | */ 253 | public function to_html($data = NULL) 254 | { 255 | // If no data is passed as a parameter, then use the data passed 256 | // via the constructor 257 | if ($data === NULL && func_num_args() === 0) 258 | { 259 | $data = $this->_data; 260 | } 261 | 262 | // Cast as an array if not already 263 | if (is_array($data) === FALSE) 264 | { 265 | $data = (array) $data; 266 | } 267 | 268 | // Check if it's a multi-dimensional array 269 | if (isset($data[0]) && count($data) !== count($data, COUNT_RECURSIVE)) 270 | { 271 | // Multi-dimensional array 272 | $headings = array_keys($data[0]); 273 | } 274 | else 275 | { 276 | // Single array 277 | $headings = array_keys($data); 278 | $data = [$data]; 279 | } 280 | 281 | // Load the table library 282 | $this->_CI->load->library('table'); 283 | 284 | $this->_CI->table->set_heading($headings); 285 | 286 | foreach ($data as $row) 287 | { 288 | // Suppressing the "array to string conversion" notice 289 | // Keep the "evil" @ here 290 | $row = @array_map('strval', $row); 291 | 292 | $this->_CI->table->add_row($row); 293 | } 294 | 295 | return $this->_CI->table->generate(); 296 | } 297 | 298 | /** 299 | * @link http://www.metashock.de/2014/02/create-csv-file-in-memory-php/ 300 | * @param mixed|NULL $data Optional data to pass, so as to override the data passed 301 | * to the constructor 302 | * @param string $delimiter The optional delimiter parameter sets the field 303 | * delimiter (one character only). NULL will use the default value (,) 304 | * @param string $enclosure The optional enclosure parameter sets the field 305 | * enclosure (one character only). NULL will use the default value (") 306 | * @return string A csv string 307 | */ 308 | public function to_csv($data = NULL, $delimiter = ',', $enclosure = '"') 309 | { 310 | // Use a threshold of 1 MB (1024 * 1024) 311 | $handle = fopen('php://temp/maxmemory:1048576', 'w'); 312 | if ($handle === FALSE) 313 | { 314 | return NULL; 315 | } 316 | 317 | // If no data is passed as a parameter, then use the data passed 318 | // via the constructor 319 | if ($data === NULL && func_num_args() === 0) 320 | { 321 | $data = $this->_data; 322 | } 323 | 324 | // If NULL, then set as the default delimiter 325 | if ($delimiter === NULL) 326 | { 327 | $delimiter = ','; 328 | } 329 | 330 | // If NULL, then set as the default enclosure 331 | if ($enclosure === NULL) 332 | { 333 | $enclosure = '"'; 334 | } 335 | 336 | // Cast as an array if not already 337 | if (is_array($data) === FALSE) 338 | { 339 | $data = (array) $data; 340 | } 341 | 342 | // Check if it's a multi-dimensional array 343 | if (isset($data[0]) && count($data) !== count($data, COUNT_RECURSIVE)) 344 | { 345 | // Multi-dimensional array 346 | $headings = array_keys($data[0]); 347 | } 348 | else 349 | { 350 | // Single array 351 | $headings = array_keys($data); 352 | $data = [$data]; 353 | } 354 | 355 | // Apply the headings 356 | fputcsv($handle, $headings, $delimiter, $enclosure); 357 | 358 | foreach ($data as $record) 359 | { 360 | // If the record is not an array, then break. This is because the 2nd param of 361 | // fputcsv() should be an array 362 | if (is_array($record) === FALSE) 363 | { 364 | break; 365 | } 366 | 367 | // Suppressing the "array to string conversion" notice. 368 | // Keep the "evil" @ here. 369 | $record = @ array_map('strval', $record); 370 | 371 | // Returns the length of the string written or FALSE 372 | fputcsv($handle, $record, $delimiter, $enclosure); 373 | } 374 | 375 | // Reset the file pointer 376 | rewind($handle); 377 | 378 | // Retrieve the csv contents 379 | $csv = stream_get_contents($handle); 380 | 381 | // Close the handle 382 | fclose($handle); 383 | 384 | return $csv; 385 | } 386 | 387 | /** 388 | * Encode data as json 389 | * 390 | * @param mixed|NULL $data Optional data to pass, so as to override the data passed 391 | * to the constructor 392 | * @return string Json representation of a value 393 | */ 394 | public function to_json($data = NULL) 395 | { 396 | // If no data is passed as a parameter, then use the data passed 397 | // via the constructor 398 | if ($data === NULL && func_num_args() === 0) 399 | { 400 | $data = $this->_data; 401 | } 402 | 403 | // Get the callback parameter (if set) 404 | $callback = $this->_CI->input->get('callback'); 405 | 406 | if (empty($callback) === TRUE) 407 | { 408 | return json_encode($data); 409 | } 410 | 411 | // We only honour a jsonp callback which are valid javascript identifiers 412 | elseif (preg_match('/^[a-z_\$][a-z0-9\$_]*(\.[a-z_\$][a-z0-9\$_]*)*$/i', $callback)) 413 | { 414 | // Return the data as encoded json with a callback 415 | return $callback.'('.json_encode($data).');'; 416 | } 417 | 418 | // An invalid jsonp callback function provided. 419 | // Though I don't believe this should be hardcoded here 420 | $data['warning'] = 'INVALID JSONP CALLBACK: '.$callback; 421 | 422 | return json_encode($data); 423 | } 424 | 425 | /** 426 | * Encode data as a serialized array 427 | * 428 | * @param mixed|NULL $data Optional data to pass, so as to override the data passed 429 | * to the constructor 430 | * @return string Serialized data 431 | */ 432 | public function to_serialized($data = NULL) 433 | { 434 | // If no data is passed as a parameter, then use the data passed 435 | // via the constructor 436 | if ($data === NULL && func_num_args() === 0) 437 | { 438 | $data = $this->_data; 439 | } 440 | 441 | return serialize($data); 442 | } 443 | 444 | /** 445 | * Format data using a PHP structure 446 | * 447 | * @param mixed|NULL $data Optional data to pass, so as to override the data passed 448 | * to the constructor 449 | * @return mixed String representation of a variable 450 | */ 451 | public function to_php($data = NULL) 452 | { 453 | // If no data is passed as a parameter, then use the data passed 454 | // via the constructor 455 | if ($data === NULL && func_num_args() === 0) 456 | { 457 | $data = $this->_data; 458 | } 459 | 460 | return var_export($data, TRUE); 461 | } 462 | 463 | // INTERNAL FUNCTIONS 464 | 465 | /** 466 | * @param string $data XML string 467 | * @return array XML element object; otherwise, empty array 468 | */ 469 | protected function _from_xml($data) 470 | { 471 | return $data ? (array) simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA) : []; 472 | } 473 | 474 | /** 475 | * @param string $data CSV string 476 | * @param string $delimiter The optional delimiter parameter sets the field 477 | * delimiter (one character only). NULL will use the default value (,) 478 | * @param string $enclosure The optional enclosure parameter sets the field 479 | * enclosure (one character only). NULL will use the default value (") 480 | * @return array A multi-dimensional array with the outer array being the number of rows 481 | * and the inner arrays the individual fields 482 | */ 483 | protected function _from_csv($data, $delimiter = ',', $enclosure = '"') 484 | { 485 | // If NULL, then set as the default delimiter 486 | if ($delimiter === NULL) 487 | { 488 | $delimiter = ','; 489 | } 490 | 491 | // If NULL, then set as the default enclosure 492 | if ($enclosure === NULL) 493 | { 494 | $enclosure = '"'; 495 | } 496 | 497 | return str_getcsv($data, $delimiter, $enclosure); 498 | } 499 | 500 | /** 501 | * @param string $data Encoded json string 502 | * @return mixed Decoded json string with leading and trailing whitespace removed 503 | */ 504 | protected function _from_json($data) 505 | { 506 | return json_decode(trim($data)); 507 | } 508 | 509 | /** 510 | * @param string $data Data to unserialize 511 | * @return mixed Unserialized data 512 | */ 513 | protected function _from_serialize($data) 514 | { 515 | return unserialize(trim($data)); 516 | } 517 | 518 | /** 519 | * @param string $data Data to trim leading and trailing whitespace 520 | * @return string Data with leading and trailing whitespace removed 521 | */ 522 | protected function _from_php($data) 523 | { 524 | return trim($data); 525 | } 526 | } 527 | -------------------------------------------------------------------------------- /application/libraries/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/logs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/models/Article_model.php: -------------------------------------------------------------------------------- 1 | db->insert($this->article_table, $data); 13 | return $this->db->insert_id(); 14 | } 15 | 16 | /** 17 | * Delete an Article 18 | * @param: {array} Article Data 19 | */ 20 | public function delete_article(array $data) 21 | { 22 | /** 23 | * Check Article exist with article_id and user_id 24 | */ 25 | $query = $this->db->get_where($this->article_table, $data); 26 | if ($this->db->affected_rows() > 0) { 27 | 28 | // Delete Article 29 | $this->db->delete($this->article_table, $data); 30 | if ($this->db->affected_rows() > 0) { 31 | return true; 32 | } 33 | return false; 34 | } 35 | return false; 36 | } 37 | 38 | /** 39 | * Update an Article 40 | * @param: {array} Article Data 41 | */ 42 | public function update_article(array $data) 43 | { 44 | /** 45 | * Check Article exist with article_id and user_id 46 | */ 47 | $query = $this->db->get_where($this->article_table, [ 48 | 'user_id' => $data['user_id'], 49 | 'id' => $data['id'], 50 | ]); 51 | 52 | if ($this->db->affected_rows() > 0) { 53 | 54 | // Update an Article 55 | $update_data = [ 56 | 'title' => $data['title'], 57 | 'description' => $data['description'], 58 | 'updated_at' => time(), 59 | ]; 60 | 61 | return $this->db->update($this->article_table, $update_data, ['id' => $query->row('id')]); 62 | } 63 | return false; 64 | } 65 | } -------------------------------------------------------------------------------- /application/models/User_model.php: -------------------------------------------------------------------------------- 1 | db->insert($this->user_table, $data); 13 | return $this->db->insert_id(); 14 | } 15 | 16 | /** 17 | * User Login 18 | * ---------------------------------- 19 | * @param: username or email address 20 | * @param: password 21 | */ 22 | public function user_login($username, $password) 23 | { 24 | $this->db->where('email', $username); 25 | $this->db->or_where('username', $username); 26 | $q = $this->db->get($this->user_table); 27 | 28 | if( $q->num_rows() ) 29 | { 30 | $user_pass = $q->row('password'); 31 | if(md5($password) === $user_pass) { 32 | return $q->row(); 33 | } 34 | return FALSE; 35 | }else{ 36 | return FALSE; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /application/models/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/third_party/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/third_party/php-jwt/BeforeValidException.php: -------------------------------------------------------------------------------- 1 | 18 | * @author Anant Narayanan 19 | * @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD 20 | * @link https://github.com/firebase/php-jwt 21 | */ 22 | class JWT 23 | { 24 | 25 | /** 26 | * When checking nbf, iat or expiration times, 27 | * we want to provide some extra leeway time to 28 | * account for clock skew. 29 | */ 30 | public static $leeway = 0; 31 | 32 | /** 33 | * Allow the current timestamp to be specified. 34 | * Useful for fixing a value within unit testing. 35 | * 36 | * Will default to PHP time() value if null. 37 | */ 38 | public static $timestamp = null; 39 | 40 | public static $supported_algs = array( 41 | 'HS256' => array('hash_hmac', 'SHA256'), 42 | 'HS512' => array('hash_hmac', 'SHA512'), 43 | 'HS384' => array('hash_hmac', 'SHA384'), 44 | 'RS256' => array('openssl', 'SHA256'), 45 | 'RS384' => array('openssl', 'SHA384'), 46 | 'RS512' => array('openssl', 'SHA512'), 47 | ); 48 | 49 | /** 50 | * Decodes a JWT string into a PHP object. 51 | * 52 | * @param string $jwt The JWT 53 | * @param string|array $key The key, or map of keys. 54 | * If the algorithm used is asymmetric, this is the public key 55 | * @param array $allowed_algs List of supported verification algorithms 56 | * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' 57 | * 58 | * @return object The JWT's payload as a PHP object 59 | * 60 | * @throws UnexpectedValueException Provided JWT was invalid 61 | * @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed 62 | * @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf' 63 | * @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat' 64 | * @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim 65 | * 66 | * @uses jsonDecode 67 | * @uses urlsafeB64Decode 68 | */ 69 | public static function decode($jwt, $key, array $allowed_algs = array()) 70 | { 71 | $timestamp = is_null(static::$timestamp) ? time() : static::$timestamp; 72 | 73 | if (empty($key)) { 74 | throw new InvalidArgumentException('Key may not be empty'); 75 | } 76 | $tks = explode('.', $jwt); 77 | if (count($tks) != 3) { 78 | throw new UnexpectedValueException('Wrong number of segments'); 79 | } 80 | list($headb64, $bodyb64, $cryptob64) = $tks; 81 | if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) { 82 | throw new UnexpectedValueException('Invalid header encoding'); 83 | } 84 | if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) { 85 | throw new UnexpectedValueException('Invalid claims encoding'); 86 | } 87 | if (false === ($sig = static::urlsafeB64Decode($cryptob64))) { 88 | throw new UnexpectedValueException('Invalid signature encoding'); 89 | } 90 | if (empty($header->alg)) { 91 | throw new UnexpectedValueException('Empty algorithm'); 92 | } 93 | if (empty(static::$supported_algs[$header->alg])) { 94 | throw new UnexpectedValueException('Algorithm not supported'); 95 | } 96 | if (!in_array($header->alg, $allowed_algs)) { 97 | throw new UnexpectedValueException('Algorithm not allowed'); 98 | } 99 | if (is_array($key) || $key instanceof \ArrayAccess) { 100 | if (isset($header->kid)) { 101 | if (!isset($key[$header->kid])) { 102 | throw new UnexpectedValueException('"kid" invalid, unable to lookup correct key'); 103 | } 104 | $key = $key[$header->kid]; 105 | } else { 106 | throw new UnexpectedValueException('"kid" empty, unable to lookup correct key'); 107 | } 108 | } 109 | 110 | // Check the signature 111 | if (!static::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) { 112 | throw new SignatureInvalidException('Signature verification failed'); 113 | } 114 | 115 | // Check if the nbf if it is defined. This is the time that the 116 | // token can actually be used. If it's not yet that time, abort. 117 | if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) { 118 | throw new BeforeValidException( 119 | 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf) 120 | ); 121 | } 122 | 123 | // Check that this token has been created before 'now'. This prevents 124 | // using tokens that have been created for later use (and haven't 125 | // correctly used the nbf claim). 126 | if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) { 127 | throw new BeforeValidException( 128 | 'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat) 129 | ); 130 | } 131 | 132 | // Check if this token has expired. 133 | if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) { 134 | throw new ExpiredException('Expired token'); 135 | } 136 | 137 | return $payload; 138 | } 139 | 140 | /** 141 | * Converts and signs a PHP object or array into a JWT string. 142 | * 143 | * @param object|array $payload PHP object or array 144 | * @param string $key The secret key. 145 | * If the algorithm used is asymmetric, this is the private key 146 | * @param string $alg The signing algorithm. 147 | * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' 148 | * @param mixed $keyId 149 | * @param array $head An array with header elements to attach 150 | * 151 | * @return string A signed JWT 152 | * 153 | * @uses jsonEncode 154 | * @uses urlsafeB64Encode 155 | */ 156 | public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null) 157 | { 158 | $header = array('typ' => 'JWT', 'alg' => $alg); 159 | if ($keyId !== null) { 160 | $header['kid'] = $keyId; 161 | } 162 | if ( isset($head) && is_array($head) ) { 163 | $header = array_merge($head, $header); 164 | } 165 | $segments = array(); 166 | $segments[] = static::urlsafeB64Encode(static::jsonEncode($header)); 167 | $segments[] = static::urlsafeB64Encode(static::jsonEncode($payload)); 168 | $signing_input = implode('.', $segments); 169 | 170 | $signature = static::sign($signing_input, $key, $alg); 171 | $segments[] = static::urlsafeB64Encode($signature); 172 | 173 | return implode('.', $segments); 174 | } 175 | 176 | /** 177 | * Sign a string with a given key and algorithm. 178 | * 179 | * @param string $msg The message to sign 180 | * @param string|resource $key The secret key 181 | * @param string $alg The signing algorithm. 182 | * Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' 183 | * 184 | * @return string An encrypted message 185 | * 186 | * @throws DomainException Unsupported algorithm was specified 187 | */ 188 | public static function sign($msg, $key, $alg = 'HS256') 189 | { 190 | if (empty(static::$supported_algs[$alg])) { 191 | throw new DomainException('Algorithm not supported'); 192 | } 193 | list($function, $algorithm) = static::$supported_algs[$alg]; 194 | switch($function) { 195 | case 'hash_hmac': 196 | return hash_hmac($algorithm, $msg, $key, true); 197 | case 'openssl': 198 | $signature = ''; 199 | $success = openssl_sign($msg, $signature, $key, $algorithm); 200 | if (!$success) { 201 | throw new DomainException("OpenSSL unable to sign data"); 202 | } else { 203 | return $signature; 204 | } 205 | } 206 | } 207 | 208 | /** 209 | * Verify a signature with the message, key and method. Not all methods 210 | * are symmetric, so we must have a separate verify and sign method. 211 | * 212 | * @param string $msg The original message (header and body) 213 | * @param string $signature The original signature 214 | * @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key 215 | * @param string $alg The algorithm 216 | * 217 | * @return bool 218 | * 219 | * @throws DomainException Invalid Algorithm or OpenSSL failure 220 | */ 221 | private static function verify($msg, $signature, $key, $alg) 222 | { 223 | if (empty(static::$supported_algs[$alg])) { 224 | throw new DomainException('Algorithm not supported'); 225 | } 226 | 227 | list($function, $algorithm) = static::$supported_algs[$alg]; 228 | switch($function) { 229 | case 'openssl': 230 | $success = openssl_verify($msg, $signature, $key, $algorithm); 231 | if ($success === 1) { 232 | return true; 233 | } elseif ($success === 0) { 234 | return false; 235 | } 236 | // returns 1 on success, 0 on failure, -1 on error. 237 | throw new DomainException( 238 | 'OpenSSL error: ' . openssl_error_string() 239 | ); 240 | case 'hash_hmac': 241 | default: 242 | $hash = hash_hmac($algorithm, $msg, $key, true); 243 | if (function_exists('hash_equals')) { 244 | return hash_equals($signature, $hash); 245 | } 246 | $len = min(static::safeStrlen($signature), static::safeStrlen($hash)); 247 | 248 | $status = 0; 249 | for ($i = 0; $i < $len; $i++) { 250 | $status |= (ord($signature[$i]) ^ ord($hash[$i])); 251 | } 252 | $status |= (static::safeStrlen($signature) ^ static::safeStrlen($hash)); 253 | 254 | return ($status === 0); 255 | } 256 | } 257 | 258 | /** 259 | * Decode a JSON string into a PHP object. 260 | * 261 | * @param string $input JSON string 262 | * 263 | * @return object Object representation of JSON string 264 | * 265 | * @throws DomainException Provided string was invalid JSON 266 | */ 267 | public static function jsonDecode($input) 268 | { 269 | if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) { 270 | /** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you 271 | * to specify that large ints (like Steam Transaction IDs) should be treated as 272 | * strings, rather than the PHP default behaviour of converting them to floats. 273 | */ 274 | $obj = json_decode($input, false, 512, JSON_BIGINT_AS_STRING); 275 | } else { 276 | /** Not all servers will support that, however, so for older versions we must 277 | * manually detect large ints in the JSON string and quote them (thus converting 278 | *them to strings) before decoding, hence the preg_replace() call. 279 | */ 280 | $max_int_length = strlen((string) PHP_INT_MAX) - 1; 281 | $json_without_bigints = preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input); 282 | $obj = json_decode($json_without_bigints); 283 | } 284 | 285 | if (function_exists('json_last_error') && $errno = json_last_error()) { 286 | static::handleJsonError($errno); 287 | } elseif ($obj === null && $input !== 'null') { 288 | throw new DomainException('Null result with non-null input'); 289 | } 290 | return $obj; 291 | } 292 | 293 | /** 294 | * Encode a PHP object into a JSON string. 295 | * 296 | * @param object|array $input A PHP object or array 297 | * 298 | * @return string JSON representation of the PHP object or array 299 | * 300 | * @throws DomainException Provided object could not be encoded to valid JSON 301 | */ 302 | public static function jsonEncode($input) 303 | { 304 | $json = json_encode($input); 305 | if (function_exists('json_last_error') && $errno = json_last_error()) { 306 | static::handleJsonError($errno); 307 | } elseif ($json === 'null' && $input !== null) { 308 | throw new DomainException('Null result with non-null input'); 309 | } 310 | return $json; 311 | } 312 | 313 | /** 314 | * Decode a string with URL-safe Base64. 315 | * 316 | * @param string $input A Base64 encoded string 317 | * 318 | * @return string A decoded string 319 | */ 320 | public static function urlsafeB64Decode($input) 321 | { 322 | $remainder = strlen($input) % 4; 323 | if ($remainder) { 324 | $padlen = 4 - $remainder; 325 | $input .= str_repeat('=', $padlen); 326 | } 327 | return base64_decode(strtr($input, '-_', '+/')); 328 | } 329 | 330 | /** 331 | * Encode a string with URL-safe Base64. 332 | * 333 | * @param string $input The string you want encoded 334 | * 335 | * @return string The base64 encode of what you passed in 336 | */ 337 | public static function urlsafeB64Encode($input) 338 | { 339 | return str_replace('=', '', strtr(base64_encode($input), '+/', '-_')); 340 | } 341 | 342 | /** 343 | * Helper method to create a JSON error. 344 | * 345 | * @param int $errno An error number from json_last_error() 346 | * 347 | * @return void 348 | */ 349 | private static function handleJsonError($errno) 350 | { 351 | $messages = array( 352 | JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', 353 | JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON', 354 | JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', 355 | JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', 356 | JSON_ERROR_UTF8 => 'Malformed UTF-8 characters' //PHP >= 5.3.3 357 | ); 358 | throw new DomainException( 359 | isset($messages[$errno]) 360 | ? $messages[$errno] 361 | : 'Unknown JSON error: ' . $errno 362 | ); 363 | } 364 | 365 | /** 366 | * Get the number of bytes in cryptographic strings. 367 | * 368 | * @param string 369 | * 370 | * @return int 371 | */ 372 | private static function safeStrlen($str) 373 | { 374 | if (function_exists('mb_strlen')) { 375 | return mb_strlen($str, '8bit'); 376 | } 377 | return strlen($str); 378 | } 379 | } 380 | -------------------------------------------------------------------------------- /application/third_party/php-jwt/SignatureInvalidException.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | An uncaught Exception was encountered 4 | 5 | Type: 6 | Message: 7 | Filename: getFile(), "\n"; ?> 8 | Line Number: getLine(); ?> 9 | 10 | 11 | 12 | Backtrace: 13 | getTrace() as $error): ?> 14 | 15 | File: 16 | Line: 17 | Function: 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /application/views/errors/cli/error_general.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | A PHP Error was encountered 4 | 5 | Severity: 6 | Message: 7 | Filename: 8 | Line Number: 9 | 10 | 11 | 12 | Backtrace: 13 | 14 | 15 | File: 16 | Line: 17 | Function: 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /application/views/errors/cli/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/views/errors/html/error_404.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 404 Page Not Found 8 | 57 | 58 | 59 |
60 |

61 | 62 |
63 | 64 | -------------------------------------------------------------------------------- /application/views/errors/html/error_db.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | Database Error 8 | 57 | 58 | 59 |
60 |

61 | 62 |
63 | 64 | -------------------------------------------------------------------------------- /application/views/errors/html/error_exception.php: -------------------------------------------------------------------------------- 1 | 4 | 5 |
6 | 7 |

An uncaught Exception was encountered

8 | 9 |

Type:

10 |

Message:

11 |

Filename: getFile(); ?>

12 |

Line Number: getLine(); ?>

13 | 14 | 15 | 16 |

Backtrace:

17 | getTrace() as $error): ?> 18 | 19 | 20 | 21 |

22 | File:
23 | Line:
24 | Function: 25 |

26 | 27 | 28 | 29 | 30 | 31 | 32 |
-------------------------------------------------------------------------------- /application/views/errors/html/error_general.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | Error 8 | 57 | 58 | 59 |
60 |

61 | 62 |
63 | 64 | -------------------------------------------------------------------------------- /application/views/errors/html/error_php.php: -------------------------------------------------------------------------------- 1 | 4 | 5 |
6 | 7 |

A PHP Error was encountered

8 | 9 |

Severity:

10 |

Message:

11 |

Filename:

12 |

Line Number:

13 | 14 | 15 | 16 |

Backtrace:

17 | 18 | 19 | 20 | 21 |

22 | File:
23 | Line:
24 | Function: 25 |

26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
-------------------------------------------------------------------------------- /application/views/errors/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/views/errors/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 403 Forbidden 5 | 6 | 7 | 8 |

Directory access is forbidden.

9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/views/welcome_message.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | Welcome to CodeIgniter 8 | 9 | 67 | 68 | 69 | 70 |
71 |

Welcome to CodeIgniter!

72 | 73 |
74 |

The page you are looking at is being generated dynamically by CodeIgniter.

75 | 76 |

If you would like to edit this page you'll find it located at:

77 | application/views/welcome_message.php 78 | 79 |

The corresponding controller for this page is found at:

80 | application/controllers/Welcome.php 81 | 82 |

If you are exploring CodeIgniter for the very first time, you should start by reading the User Guide.

83 |
84 | 85 | 86 |
87 | 88 | 89 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 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 | "irc": "irc://irc.freenode.net/codeigniter", 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 | } 24 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to CodeIgniter 2 | 3 | 4 | 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. 5 | 6 | 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: 7 | 8 | 1. There is not already an open Issue 9 | 2. The issue has already been fixed (check the develop branch, or look for closed Issues) 10 | 3. Is it something really obvious that you can fix yourself? 11 | 12 | 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. 13 | 14 | ## Guidelines 15 | 16 | Before we look into how, here are the guidelines. If your Pull Requests fail 17 | to pass these guidelines it will be declined and you will need to re-submit 18 | when you’ve made the changes. This might sound a bit tough, but it is required 19 | for us to maintain quality of the code-base. 20 | 21 | ### PHP Style 22 | 23 | All code must meet the [Style Guide](https://codeigniter.com/user_guide/general/styleguide.html), which is 24 | 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. 25 | 26 | ### Documentation 27 | 28 | 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. 29 | 30 | ### Compatibility 31 | 32 | CodeIgniter recommends PHP 5.4 or newer to be used, but it should be 33 | compatible with PHP 5.2.4 so all code supplied must stick to this 34 | requirement. If PHP 5.3 (and above) functions or features are used then 35 | there must be a fallback for PHP 5.2.4. 36 | 37 | ### Branching 38 | 39 | 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 40 | 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. 41 | 42 | 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. 43 | 44 | ### Signing 45 | 46 | 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. 47 | 48 | `git commit --signoff` 49 | 50 | or simply 51 | 52 | `git commit -s` 53 | 54 | This will sign your commits with the information setup in your git config, e.g. 55 | 56 | `Signed-off-by: John Q Public ` 57 | 58 | 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. 59 | 60 | 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. 61 | 62 | 63 | ## How-to Guide 64 | 65 | 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). 66 | 67 | 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. 68 | 69 | 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". 70 | 71 | 1. Set up Git (Windows, Mac & Linux) 72 | 2. Go to the CodeIgniter repo 73 | 3. Fork it 74 | 4. Clone your CodeIgniter repo: git@github.com:/CodeIgniter.git 75 | 5. Checkout the "develop" branch At this point you are ready to start making changes. 76 | 6. Fix existing bugs on the Issue tracker after taking a look to see nobody else is working on them. 77 | 7. Commit the files 78 | 8. Push your develop branch to your fork 79 | 9. Send a pull request [http://help.github.com/send-pull-requests/](http://help.github.com/send-pull-requests/) 80 | 81 | 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. 82 | 83 | 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. 84 | 85 | ### Keeping your fork up-to-date 86 | 87 | 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. 88 | 89 | If you are using command-line you can do the following: 90 | 91 | 1. `git remote add codeigniter git://github.com/bcit-ci/CodeIgniter.git` 92 | 2. `git pull codeigniter develop` 93 | 3. `git push origin develop` 94 | 95 | Now your fork is up to date. This should be done regularly, or before you send a pull request at least. -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | =')) 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'; 316 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 - 2017, 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. -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # CodeIgniter Rest Server (API) Application 2 | 3 | [Source Code](https://github.com/jeevan15498/CodeIgniter-Rest-Server-API-Application) 4 | 5 | [Videos](https://www.youtube.com/watch?v=Uv36jDf5his&t=432s&list=PLmrTMUhqzS3iogaInFhqYJpV86NGUbthc&index=2) 6 | 7 | # Requirements 8 | 9 | - XAMPP 10 | - PHP 5.6.8 11 | 12 | 13 | # Libraries 14 | 15 | - [Rest Server](https://github.com/chriskacerguis/codeigniter-restserver) 16 | - [php-jwt](https://github.com/firebase/php-jwt) 17 | 18 | # Note 19 | 20 | It is important to understand that the purpose of using JWT is NOT to hide or obscure data in any way. The reason why JWT are used is to prove that the sent data was actually created by an authentic source. 21 | 22 | Since JWT are signed and encoded only, and since JWT are not encrypted, JWT do not guarantee any security for sensitive data. 23 | 24 | # Git Commit's 25 | 26 | - Deleta an Article 27 | - Update and Article 28 | - Create/Add a new Article with User Authorization 29 | - Generate PHP Token for User Authorization Using `PHP-JWT` Library 30 | - User Login flow on a REST API 31 | - User Registration flow on a REST API 32 | - Setup Project for User login and register 33 | - Getting Started Again --------------------------------------------------------------------------------