├── .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
│ ├── memcached.php
│ ├── migration.php
│ ├── mimes.php
│ ├── oauth2.php
│ ├── profiler.php
│ ├── routes.php
│ ├── smileys.php
│ └── user_agents.php
├── controllers
│ ├── Errors.php
│ ├── Welcome.php
│ └── index.html
├── core
│ ├── MY_Controller.php
│ ├── MY_Loader.php
│ ├── MY_Router.php
│ └── index.html
├── helpers
│ └── index.html
├── hooks
│ └── index.html
├── index.html
├── language
│ ├── english
│ │ └── index.html
│ └── index.html
├── libraries
│ ├── Authenticate.php
│ ├── Middleware.php
│ ├── MyAPI.php
│ ├── MyOAuth2.php
│ ├── RESTful.php
│ ├── Request.php
│ ├── Response.php
│ └── index.html
├── logs
│ └── index.html
├── models
│ ├── index.html
│ └── welcome_model.php
├── modules
│ ├── oauth2
│ │ ├── config
│ │ │ └── routes.php
│ │ └── controllers
│ │ │ ├── OAuth2_api_controller.php
│ │ │ └── index.html
│ └── user
│ │ ├── config
│ │ └── routes.php
│ │ ├── controllers
│ │ ├── User_api_controller.php
│ │ ├── User_controller.php
│ │ └── index.html
│ │ ├── models
│ │ └── User_model.php
│ │ └── views
│ │ └── User_view.php
├── third_party
│ ├── MX
│ │ ├── Base.php
│ │ ├── Ci.php
│ │ ├── Config.php
│ │ ├── Controller.php
│ │ ├── Lang.php
│ │ ├── Loader.php
│ │ ├── Modules.php
│ │ └── Router.php
│ └── index.html
└── 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
├── index.php
├── license.md
├── orm
├── classes
│ ├── Base
│ │ ├── User.php
│ │ └── UserQuery.php
│ ├── Map
│ │ └── UserTableMap.php
│ ├── User.php
│ └── UserQuery.php
├── config.php
└── schema.xml
├── propel
├── propel.yml
├── readme.md
├── sql
├── development.sql
├── oauth.sql
└── sqldb.map
├── test
└── api_test.php
└── vendor
└── .gitkeep
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | application/cache/*
4 | !application/cache/index.html
5 | !application/cache/.htaccess
6 |
7 | application/logs/*
8 | !application/logs/index.html
9 | !application/logs/.htaccess
10 |
11 | user_guide_src/build/*
12 | user_guide_src/cilexer/build/*
13 | user_guide_src/cilexer/dist/*
14 | user_guide_src/cilexer/pycilexer.egg-info/*
15 | vendor/*
16 | !vendor/.gitkeep
17 | **/.DS_STORE
18 | **/.DS_Store
19 | composer.lock
20 |
21 | # IDE Files
22 | #-------------------------
23 | /nbproject/
24 | .idea/*
25 |
26 | ## Sublime Text cache files
27 | *.tmlanguage.cache
28 | *.tmPreferences.cache
29 | *.stTheme.cache
30 | *.sublime-workspace
31 | *.sublime-project
32 |
--------------------------------------------------------------------------------
/.htaccess:
--------------------------------------------------------------------------------
1 | # Apache configuration file
2 | # httpd.apache.org/docs/2.2/mod/quickreference.html
3 |
4 | # Note .htaccess files are an overhead, this logic should be in your Apache
5 | # config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html
6 |
7 | # Techniques in here adapted from all over, including:
8 | # Kroc Camen: camendesign.com/.htaccess
9 | # perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
10 | # Sample .htaccess file of CMS MODx: modxcms.com
11 |
12 |
13 | # ----------------------------------------------------------------------
14 | # Better website experience for IE users
15 | # ----------------------------------------------------------------------
16 |
17 | # Force the latest IE version, in various cases when it may fall back to IE7 mode
18 | # github.com/rails/rails/commit/123eb25#commitcomment-118920
19 | # Use ChromeFrame if it's installed for a better experience for the poor IE folk
20 |
21 |
Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/config/autoload.php: -------------------------------------------------------------------------------- 1 | 'ua'); 61 | */ 62 | $autoload['libraries'] = array( 63 | 'parser' 64 | ); 65 | 66 | /* 67 | | ------------------------------------------------------------------- 68 | | Auto-load Drivers 69 | | ------------------------------------------------------------------- 70 | | These classes are located in system/libraries/ or in your 71 | | application/libraries/ directory, but are also placed inside their 72 | | own subdirectory and they extend the CI_Driver_Library class. They 73 | | offer multiple interchangeable driver options. 74 | | 75 | | Prototype: 76 | | 77 | | $autoload['drivers'] = array('cache'); 78 | */ 79 | $autoload['drivers'] = array(); 80 | 81 | /* 82 | | ------------------------------------------------------------------- 83 | | Auto-load Helper Files 84 | | ------------------------------------------------------------------- 85 | | Prototype: 86 | | 87 | | $autoload['helper'] = array('url', 'file'); 88 | */ 89 | $autoload['helper'] = array( 90 | 'url', 91 | 'file' 92 | ); 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 | | By default CodeIgniter enables access to the $_GET array. If for some 172 | | reason you would like to disable it, set 'allow_get_array' to FALSE. 173 | | 174 | | You can optionally enable standard query string based URLs: 175 | | example.com?who=me&what=something&where=here 176 | | 177 | | Options are: TRUE or FALSE (boolean) 178 | | 179 | | The other items let you set the query string 'words' that will 180 | | invoke your controllers and its functions: 181 | | example.com/index.php?c=controller&m=function 182 | | 183 | | Please note that some of the helpers won't work as expected when 184 | | this feature is enabled, since CodeIgniter is designed primarily to 185 | | use segment based URLs. 186 | | 187 | */ 188 | $config['allow_get_array'] = TRUE; 189 | $config['enable_query_strings'] = FALSE; 190 | $config['controller_trigger'] = 'c'; 191 | $config['function_trigger'] = 'm'; 192 | $config['directory_trigger'] = 'd'; 193 | 194 | /* 195 | |-------------------------------------------------------------------------- 196 | | Error Logging Threshold 197 | |-------------------------------------------------------------------------- 198 | | 199 | | You can enable error logging by setting a threshold over zero. The 200 | | threshold determines what gets logged. Threshold options are: 201 | | 202 | | 0 = Disables logging, Error logging TURNED OFF 203 | | 1 = Error Messages (including PHP errors) 204 | | 2 = Debug Messages 205 | | 3 = Informational Messages 206 | | 4 = All Messages 207 | | 208 | | You can also pass an array with threshold levels to show individual error types 209 | | 210 | | array(2) = Debug Messages, without Error Messages 211 | | 212 | | For a live site you'll usually only enable Errors (1) to be logged otherwise 213 | | your log files will fill up very fast. 214 | | 215 | */ 216 | $config['log_threshold'] = 0; 217 | 218 | /* 219 | |-------------------------------------------------------------------------- 220 | | Error Logging Directory Path 221 | |-------------------------------------------------------------------------- 222 | | 223 | | Leave this BLANK unless you would like to set something other than the default 224 | | application/logs/ directory. Use a full server path with trailing slash. 225 | | 226 | */ 227 | $config['log_path'] = ''; 228 | 229 | /* 230 | |-------------------------------------------------------------------------- 231 | | Log File Extension 232 | |-------------------------------------------------------------------------- 233 | | 234 | | The default filename extension for log files. The default 'php' allows for 235 | | protecting the log files via basic scripting, when they are to be stored 236 | | under a publicly accessible directory. 237 | | 238 | | Note: Leaving it blank will default to 'php'. 239 | | 240 | */ 241 | $config['log_file_extension'] = ''; 242 | 243 | /* 244 | |-------------------------------------------------------------------------- 245 | | Log File Permissions 246 | |-------------------------------------------------------------------------- 247 | | 248 | | The file system permissions to be applied on newly created log files. 249 | | 250 | | IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal 251 | | integer notation (i.e. 0700, 0644, etc.) 252 | */ 253 | $config['log_file_permissions'] = 0644; 254 | 255 | /* 256 | |-------------------------------------------------------------------------- 257 | | Date Format for Logs 258 | |-------------------------------------------------------------------------- 259 | | 260 | | Each item that is logged has an associated date. You can use PHP date 261 | | codes to set your own date formatting 262 | | 263 | */ 264 | $config['log_date_format'] = 'Y-m-d H:i:s'; 265 | 266 | /* 267 | |-------------------------------------------------------------------------- 268 | | Error Views Directory Path 269 | |-------------------------------------------------------------------------- 270 | | 271 | | Leave this BLANK unless you would like to set something other than the default 272 | | application/views/errors/ directory. Use a full server path with trailing slash. 273 | | 274 | */ 275 | $config['error_views_path'] = ''; 276 | 277 | /* 278 | |-------------------------------------------------------------------------- 279 | | Cache Directory Path 280 | |-------------------------------------------------------------------------- 281 | | 282 | | Leave this BLANK unless you would like to set something other than the default 283 | | application/cache/ directory. Use a full server path with trailing slash. 284 | | 285 | */ 286 | $config['cache_path'] = ''; 287 | 288 | /* 289 | |-------------------------------------------------------------------------- 290 | | Cache Include Query String 291 | |-------------------------------------------------------------------------- 292 | | 293 | | Whether to take the URL query string into consideration when generating 294 | | output cache files. Valid options are: 295 | | 296 | | FALSE = Disabled 297 | | TRUE = Enabled, take all query parameters into account. 298 | | Please be aware that this may result in numerous cache 299 | | files generated for the same page over and over again. 300 | | array('q') = Enabled, but only take into account the specified list 301 | | of query parameters. 302 | | 303 | */ 304 | $config['cache_query_string'] = FALSE; 305 | 306 | /* 307 | |-------------------------------------------------------------------------- 308 | | Encryption Key 309 | |-------------------------------------------------------------------------- 310 | | 311 | | If you use the Encryption class, you must set an encryption key. 312 | | See the user guide for more info. 313 | | 314 | | http://codeigniter.com/user_guide/libraries/encryption.html 315 | | 316 | */ 317 | $config['encryption_key'] = ''; 318 | 319 | /* 320 | |-------------------------------------------------------------------------- 321 | | Session Variables 322 | |-------------------------------------------------------------------------- 323 | | 324 | | 'sess_driver' 325 | | 326 | | The storage driver to use: files, database, redis, memcached 327 | | 328 | | 'sess_cookie_name' 329 | | 330 | | The session cookie name, must contain only [0-9a-z_-] characters 331 | | 332 | | 'sess_expiration' 333 | | 334 | | The number of SECONDS you want the session to last. 335 | | Setting to 0 (zero) means expire when the browser is closed. 336 | | 337 | | 'sess_save_path' 338 | | 339 | | The location to save sessions to, driver dependent. 340 | | 341 | | For the 'files' driver, it's a path to a writable directory. 342 | | WARNING: Only absolute paths are supported! 343 | | 344 | | For the 'database' driver, it's a table name. 345 | | Please read up the manual for the format with other session drivers. 346 | | 347 | | IMPORTANT: You are REQUIRED to set a valid save path! 348 | | 349 | | 'sess_match_ip' 350 | | 351 | | Whether to match the user's IP address when reading the session data. 352 | | 353 | | 'sess_time_to_update' 354 | | 355 | | How many seconds between CI regenerating the session ID. 356 | | 357 | | 'sess_regenerate_destroy' 358 | | 359 | | Whether to destroy session data associated with the old session ID 360 | | when auto-regenerating the session ID. When set to FALSE, the data 361 | | will be later deleted by the garbage collector. 362 | | 363 | | Other session cookie settings are shared with the rest of the application, 364 | | except for 'cookie_prefix' and 'cookie_httponly', which are ignored here. 365 | | 366 | */ 367 | $config['sess_driver'] = 'files'; 368 | $config['sess_cookie_name'] = 'ci_session'; 369 | $config['sess_expiration'] = 7200; 370 | $config['sess_save_path'] = sys_get_temp_dir(); 371 | $config['sess_match_ip'] = FALSE; 372 | $config['sess_time_to_update'] = 300; 373 | $config['sess_regenerate_destroy'] = FALSE; 374 | 375 | /* 376 | |-------------------------------------------------------------------------- 377 | | Cookie Related Variables 378 | |-------------------------------------------------------------------------- 379 | | 380 | | 'cookie_prefix' = Set a cookie name prefix if you need to avoid collisions 381 | | 'cookie_domain' = Set to .your-domain.com for site-wide cookies 382 | | 'cookie_path' = Typically will be a forward slash 383 | | 'cookie_secure' = Cookie will only be set if a secure HTTPS connection exists. 384 | | 'cookie_httponly' = Cookie will only be accessible via HTTP(S) (no javascript) 385 | | 386 | | Note: These settings (with the exception of 'cookie_prefix' and 387 | | 'cookie_httponly') will also affect sessions. 388 | | 389 | */ 390 | $config['cookie_prefix'] = ''; 391 | $config['cookie_domain'] = ''; 392 | $config['cookie_path'] = '/'; 393 | $config['cookie_secure'] = FALSE; 394 | $config['cookie_httponly'] = FALSE; 395 | 396 | /* 397 | |-------------------------------------------------------------------------- 398 | | Standardize newlines 399 | |-------------------------------------------------------------------------- 400 | | 401 | | Determines whether to standardize newline characters in input data, 402 | | meaning to replace \r\n, \r, \n occurrences with the PHP_EOL value. 403 | | 404 | | This is particularly useful for portability between UNIX-based OSes, 405 | | (usually \n) and Windows (\r\n). 406 | | 407 | */ 408 | $config['standardize_newlines'] = FALSE; 409 | 410 | /* 411 | |-------------------------------------------------------------------------- 412 | | Global XSS Filtering 413 | |-------------------------------------------------------------------------- 414 | | 415 | | Determines whether the XSS filter is always active when GET, POST or 416 | | COOKIE data is encountered 417 | | 418 | | WARNING: This feature is DEPRECATED and currently available only 419 | | for backwards compatibility purposes! 420 | | 421 | */ 422 | $config['global_xss_filtering'] = FALSE; 423 | 424 | /* 425 | |-------------------------------------------------------------------------- 426 | | Cross Site Request Forgery 427 | |-------------------------------------------------------------------------- 428 | | Enables a CSRF cookie token to be set. When set to TRUE, token will be 429 | | checked on a submitted form. If you are accepting user data, it is strongly 430 | | recommended CSRF protection be enabled. 431 | | 432 | | 'csrf_token_name' = The token name 433 | | 'csrf_cookie_name' = The cookie name 434 | | 'csrf_expire' = The number in seconds the token should expire. 435 | | 'csrf_regenerate' = Regenerate token on every submission 436 | | 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks 437 | */ 438 | $config['csrf_protection'] = FALSE; 439 | $config['csrf_token_name'] = 'csrf_test_name'; 440 | $config['csrf_cookie_name'] = 'csrf_cookie_name'; 441 | $config['csrf_expire'] = 7200; 442 | $config['csrf_regenerate'] = TRUE; 443 | $config['csrf_exclude_uris'] = array(); 444 | 445 | /* 446 | |-------------------------------------------------------------------------- 447 | | Output Compression 448 | |-------------------------------------------------------------------------- 449 | | 450 | | Enables Gzip output compression for faster page loads. When enabled, 451 | | the output class will test whether your server supports Gzip. 452 | | Even if it does, however, not all browsers support compression 453 | | so enable only if you are reasonably sure your visitors can handle it. 454 | | 455 | | Only used if zlib.output_compression is turned off in your php.ini. 456 | | Please do not use it together with httpd-level output compression. 457 | | 458 | | VERY IMPORTANT: If you are getting a blank page when compression is enabled it 459 | | means you are prematurely outputting something to your browser. It could 460 | | even be a line of whitespace at the end of one of your scripts. For 461 | | compression to work, nothing can be sent before the output buffer is called 462 | | by the output class. Do not 'echo' any values with compression enabled. 463 | | 464 | */ 465 | $config['compress_output'] = FALSE; 466 | 467 | /* 468 | |-------------------------------------------------------------------------- 469 | | Master Time Reference 470 | |-------------------------------------------------------------------------- 471 | | 472 | | Options are 'local' or any PHP supported timezone. This preference tells 473 | | the system whether to use your server's local time as the master 'now' 474 | | reference, or convert it to the configured one timezone. See the 'date 475 | | helper' page of the user guide for information regarding date handling. 476 | | 477 | */ 478 | $config['time_reference'] = 'local'; 479 | 480 | /* 481 | |-------------------------------------------------------------------------- 482 | | Rewrite PHP Short Tags 483 | |-------------------------------------------------------------------------- 484 | | 485 | | If your PHP installation does not have short tag support enabled CI 486 | | can rewrite the tags on-the-fly, enabling you to utilize that syntax 487 | | in your view files. Options are TRUE or FALSE (boolean) 488 | | 489 | | Note: You need to have eval() enabled for this to work. 490 | | 491 | */ 492 | $config['rewrite_short_tags'] = FALSE; 493 | 494 | /* 495 | |-------------------------------------------------------------------------- 496 | | Reverse Proxy IPs 497 | |-------------------------------------------------------------------------- 498 | | 499 | | If your server is behind a reverse proxy, you must whitelist the proxy 500 | | IP addresses from which CodeIgniter should trust headers such as 501 | | HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify 502 | | the visitor's IP address. 503 | | 504 | | You can use both an array or a comma-separated list of proxy addresses, 505 | | as well as specifying whole subnets. Here are a few examples: 506 | | 507 | | Comma-separated: '10.0.1.200,192.168.5.0/24' 508 | | Array: array('10.0.1.200', '192.168.5.0/24') 509 | */ 510 | $config['proxy_ips'] = ''; 511 | -------------------------------------------------------------------------------- /application/config/constants.php: -------------------------------------------------------------------------------- 1 | db->last_query() and profiling of DB queries. 63 | | When you run a query, with this setting set to TRUE (default), 64 | | CodeIgniter will store the SQL statement for debugging purposes. 65 | | However, this may cause high memory usage, especially if you run 66 | | a lot of SQL queries ... disable this to avoid that problem. 67 | | 68 | | The $active_group variable lets you choose which connection group to 69 | | make active. By default there is only one group (the 'default' group). 70 | | 71 | | The $query_builder variables lets you determine whether or not to load 72 | | the query builder class. 73 | */ 74 | $active_group = (ENVIRONMENT !== 'production') ? 'default' : 'production'; 75 | $query_builder = TRUE; 76 | 77 | $db['default'] = array( 78 | 'dsn' => '', 79 | 'hostname' => 'localhost', 80 | 'username' => 'root', 81 | 'password' => 'root', 82 | 'database' => 'dbcodeigniter', 83 | 'dbdriver' => 'mysqli', 84 | 'dbprefix' => '', 85 | 'pconnect' => FALSE, 86 | 'db_debug' => (ENVIRONMENT !== 'production'), 87 | 'cache_on' => FALSE, 88 | 'cachedir' => '', 89 | 'char_set' => 'utf8', 90 | 'dbcollat' => 'utf8_general_ci', 91 | 'swap_pre' => '', 92 | 'encrypt' => FALSE, 93 | 'compress' => FALSE, 94 | 'stricton' => FALSE, 95 | 'failover' => array(), 96 | 'save_queries' => TRUE 97 | ); 98 | 99 | $db['production'] = array( 100 | 'dsn' => '', 101 | 'hostname' => 'localhost', 102 | 'username' => 'root', 103 | 'password' => 'root', 104 | 'database' => 'dbcodeigniter', 105 | 'dbdriver' => 'mysqli', 106 | 'dbprefix' => '', 107 | 'pconnect' => FALSE, 108 | 'db_debug' => (ENVIRONMENT !== 'production'), 109 | 'cache_on' => FALSE, 110 | 'cachedir' => '', 111 | 'char_set' => 'utf8', 112 | 'dbcollat' => 'utf8_general_ci', 113 | 'swap_pre' => '', 114 | 'encrypt' => FALSE, 115 | 'compress' => FALSE, 116 | 'stricton' => FALSE, 117 | 'failover' => array(), 118 | 'save_queries' => TRUE 119 | ); 120 | 121 | // OAuth2 122 | $db['oauth'] = array( 123 | 'dsn' => 'mysql:dbname=dbcodeigniter;host=localhost', 124 | 'username' => 'root', 125 | 'password' => 'root' 126 | ); 127 | -------------------------------------------------------------------------------- /application/config/doctypes.php: -------------------------------------------------------------------------------- 1 | '', 7 | 'xhtml1-strict' => '', 8 | 'xhtml1-trans' => '', 9 | 'xhtml1-frame' => '', 10 | 'xhtml-basic11' => '', 11 | 'html5' => '', 12 | 'html4-strict' => '', 13 | 'html4-trans' => '', 14 | 'html4-frame' => '', 15 | 'mathml1' => '', 16 | 'mathml2' => '', 17 | 'svg10' => '', 18 | 'svg11' => '', 19 | 'svg11-basic' => '', 20 | 'svg11-tiny' => '', 21 | 'xhtml-math-svg-xh' => '', 22 | 'xhtml-math-svg-sh' => '', 23 | 'xhtml-rdfa-1' => '', 24 | 'xhtml-rdfa-2' => '' 25 | ); 26 | -------------------------------------------------------------------------------- /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 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/config/memcached.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 | 'png' => array('image/png', 'image/x-png'), 81 | 'tiff' => 'image/tiff', 82 | 'tif' => 'image/tiff', 83 | 'css' => array('text/css', 'text/plain'), 84 | 'html' => array('text/html', 'text/plain'), 85 | 'htm' => array('text/html', 'text/plain'), 86 | 'shtml' => array('text/html', 'text/plain'), 87 | 'txt' => 'text/plain', 88 | 'text' => 'text/plain', 89 | 'log' => array('text/plain', 'text/x-log'), 90 | 'rtx' => 'text/richtext', 91 | 'rtf' => 'text/rtf', 92 | 'xml' => array('application/xml', 'text/xml', 'text/plain'), 93 | 'xsl' => array('application/xml', 'text/xsl', 'text/xml'), 94 | 'mpeg' => 'video/mpeg', 95 | 'mpg' => 'video/mpeg', 96 | 'mpe' => 'video/mpeg', 97 | 'qt' => 'video/quicktime', 98 | 'mov' => 'video/quicktime', 99 | 'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'), 100 | 'movie' => 'video/x-sgi-movie', 101 | 'doc' => array('application/msword', 'application/vnd.ms-office'), 102 | 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'), 103 | 'dot' => array('application/msword', 'application/vnd.ms-office'), 104 | 'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'), 105 | 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'), 106 | 'word' => array('application/msword', 'application/octet-stream'), 107 | 'xl' => 'application/excel', 108 | 'eml' => 'message/rfc822', 109 | 'json' => array('application/json', 'text/json'), 110 | 'pem' => array('application/x-x509-user-cert', 'application/x-pem-file', 'application/octet-stream'), 111 | 'p10' => array('application/x-pkcs10', 'application/pkcs10'), 112 | 'p12' => 'application/x-pkcs12', 113 | 'p7a' => 'application/x-pkcs7-signature', 114 | 'p7c' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'), 115 | 'p7m' => array('application/pkcs7-mime', 'application/x-pkcs7-mime'), 116 | 'p7r' => 'application/x-pkcs7-certreqresp', 117 | 'p7s' => 'application/pkcs7-signature', 118 | 'crt' => array('application/x-x509-ca-cert', 'application/x-x509-user-cert', 'application/pkix-cert'), 119 | 'crl' => array('application/pkix-crl', 'application/pkcs-crl'), 120 | 'der' => 'application/x-x509-ca-cert', 121 | 'kdb' => 'application/octet-stream', 122 | 'pgp' => 'application/pgp', 123 | 'gpg' => 'application/gpg-keys', 124 | 'sst' => 'application/octet-stream', 125 | 'csr' => 'application/octet-stream', 126 | 'rsa' => 'application/x-pkcs7', 127 | 'cer' => array('application/pkix-cert', 'application/x-x509-ca-cert'), 128 | '3g2' => 'video/3gpp2', 129 | '3gp' => array('video/3gp', 'video/3gpp'), 130 | 'mp4' => 'video/mp4', 131 | 'm4a' => 'audio/x-m4a', 132 | 'f4v' => 'video/mp4', 133 | 'webm' => 'video/webm', 134 | 'aac' => 'audio/x-acc', 135 | 'm4u' => 'application/vnd.mpegurl', 136 | 'm3u' => 'text/plain', 137 | 'xspf' => 'application/xspf+xml', 138 | 'vlc' => 'application/videolan', 139 | 'wmv' => array('video/x-ms-wmv', 'video/x-ms-asf'), 140 | 'au' => 'audio/x-au', 141 | 'ac3' => 'audio/ac3', 142 | 'flac' => 'audio/x-flac', 143 | 'ogg' => 'audio/ogg', 144 | 'kmz' => array('application/vnd.google-earth.kmz', 'application/zip', 'application/x-zip'), 145 | 'kml' => array('application/vnd.google-earth.kml+xml', 'application/xml', 'text/xml'), 146 | 'ics' => 'text/calendar', 147 | 'ical' => 'text/calendar', 148 | 'zsh' => 'text/x-scriptzsh', 149 | '7zip' => array('application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip'), 150 | 'cdr' => array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'), 151 | 'wma' => array('audio/x-ms-wma', 'video/x-ms-asf'), 152 | 'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'), 153 | 'svg' => array('image/svg+xml', 'application/xml', 'text/xml'), 154 | 'vcf' => 'text/x-vcard', 155 | 'srt' => array('text/srt', 'text/plain'), 156 | 'vtt' => array('text/vtt', 'text/plain'), 157 | 'ico' => array('image/x-icon', 'image/x-ico', 'image/vnd.microsoft.icon') 158 | ); 159 | -------------------------------------------------------------------------------- /application/config/oauth2.php: -------------------------------------------------------------------------------- 1 | 'mysql:dbname=dboauth;host=localhost', 17 | 'username' => 'root', 18 | 'password' => 'root' 19 | ); 20 | 21 | /** 22 | * Ignore OAuth2 authorization request. 23 | * 24 | * Example: 25 | * Class_api_controller/method_post 26 | */ 27 | $config['ignore'] = array( 28 | 'OAuth2_api_controller/client_credential_post' 29 | ); 30 | -------------------------------------------------------------------------------- /application/config/profiler.php: -------------------------------------------------------------------------------- 1 | my_controller/index 51 | | my-controller/my-method -> my_controller/my_method 52 | */ 53 | 54 | $route['default_controller'] = 'welcome'; 55 | $route['404_override'] = 'errors'; 56 | $route['translate_uri_dashes'] = FALSE; 57 | 58 | /* 59 | * API 60 | */ 61 | 62 | // OAuth 2 Module 63 | // -- Client Credentials 64 | $route['v1/login/oauth/access_token'] = 'oauth2/login/access_token'; 65 | 66 | // User Module 67 | $route['v1/user'] = 'user'; 68 | $route['v1/user/([0-9]+)'] = 'user/$1'; 69 | -------------------------------------------------------------------------------- /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/Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/core/MY_Controller.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | class MY_Controller extends CI_Controller { 16 | 17 | public $request; 18 | public $response; 19 | public $restful; 20 | public $oauth; 21 | 22 | public function __construct() { 23 | parent::__construct(); 24 | 25 | $load = $this->load; 26 | $input = $this->input; 27 | 28 | $this->load->library('Response', $load); 29 | $this->load->library('Request', array( 30 | 'load' => $load, 31 | 'input' => $input 32 | )); 33 | 34 | $request = $this->request; 35 | $response = $this->response; 36 | 37 | $this->load->library('Middleware', array( 38 | 'load' => $load, 39 | 'request' => $request, 40 | 'response' => $response 41 | )); 42 | 43 | $this->load->library('RESTful', array( 44 | 'load' => $load, 45 | 'input' => $input, 46 | 'request' => $request, 47 | 'response' => $response, 48 | 'router' => $this->router 49 | ), 'restful'); 50 | 51 | $this->oauth = $this->restful->get_oauth(); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /application/core/MY_Loader.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/helpers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/hooks/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/english/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/language/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/libraries/Authenticate.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class Authenticate { 13 | 14 | protected $request; 15 | protected $response; 16 | 17 | function __construct($request, $response) { 18 | $this->request = $request; 19 | $this->response = $response; 20 | } 21 | 22 | function guard() { 23 | // Authentication stuff goes here 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /application/libraries/Middleware.php: -------------------------------------------------------------------------------- 1 | 12 | */ 13 | class Middleware { 14 | 15 | protected $load; 16 | 17 | function __construct($params) { 18 | $this->load = $params['load']; 19 | $this->request = $params['request']; 20 | $this->response = $params['response']; 21 | 22 | // Authentication stuff 23 | // $this->authentication(); 24 | } 25 | 26 | function authentication() { 27 | $this->load->library('Authenticate'); 28 | 29 | $authenticate = new Authenticate($this->request, $this->response); 30 | $authenticate->guard(); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /application/libraries/MyAPI.php: -------------------------------------------------------------------------------- 1 | 10 | */ 11 | class MyAPI { 12 | 13 | private static $_instance = NULL; 14 | private static $_supported_formats = array( 15 | 'json' => 'application/json', 16 | 'xml' => 'application/xml' 17 | ); 18 | private static $_options = array( 19 | 'base_url' => '', 20 | 'api_key' => '', 21 | 'data_type' => 'json', 22 | 'header' => array() 23 | ); 24 | private static $_CURL_OPTS = array( 25 | CURLOPT_CONNECTTIMEOUT => 10, 26 | CURLOPT_RETURNTRANSFER => TRUE, 27 | CURLOPT_TIMEOUT => 60, 28 | CURLOPT_USERAGENT => 'myapi-php-1.0', 29 | ); 30 | 31 | /** 32 | * Create API handler 33 | * @param array $options 34 | * 35 | * Supported values: 36 | * 37 | * array( 38 | * 'base_url' => '', 39 | * 'api_key' => '', 40 | * 'data_type' => 'json', 41 | * 'header' => array() 42 | * ) 43 | * 44 | * @return MyAPI MyAPI instance 45 | */ 46 | static function create($options = array()) { 47 | $opts = array_merge(self::$_options, $options); 48 | 49 | $header = $opts['header']; 50 | $header['api-key'] = $opts['api_key']; 51 | 52 | $headers = array(); 53 | 54 | foreach ($header as $key => $value) { 55 | $headers[] = "$key: $value"; 56 | } 57 | 58 | $opts['header'] = $headers; 59 | 60 | self::$_options = $opts; 61 | 62 | if (static::$_instance === NULL) { 63 | static::$_instance = new static(); 64 | } 65 | 66 | return static::$_instance; 67 | } 68 | 69 | /** 70 | * Makes an HTTP request. This method can be overridden by subclasses if 71 | * developers want to do fancier things or use something other than curl to 72 | * make the request. 73 | * 74 | * @param string $url The URL to make the request to 75 | * @param array $params The parameters to use for the POST body 76 | * @param string $method Request method: GET, POST, PUT, DELETE, etc 77 | * @param CurlHandler $ch Initialized curl handle 78 | * 79 | * @return string The response text 80 | */ 81 | static function create_request($url, $params, $method = 'GET', $ch = NULL) { 82 | if (!$ch) { 83 | $ch = curl_init(); 84 | } 85 | 86 | $opts = self::$_CURL_OPTS; 87 | $header = self::$_options['header']; 88 | $base_url = self::$_options['base_url']; 89 | $data_type = self::$_options['data_type']; 90 | $accept_types = self::$_supported_formats; 91 | $url = $base_url . $url; 92 | 93 | $header[] = 'Accept: ' . $accept_types[$data_type]; 94 | 95 | $opts[CURLOPT_HTTPHEADER] = $header; 96 | $opts[CURLOPT_CUSTOMREQUEST] = strtoupper($method); 97 | 98 | if ($method === 'GET') { 99 | $url .= (empty($params) ? '' : '?' . http_build_query($params)); 100 | } else { 101 | $opts[CURLOPT_POSTFIELDS] = $params; 102 | } 103 | 104 | $opts[CURLOPT_URL] = $url; 105 | 106 | curl_setopt_array($ch, $opts); 107 | 108 | $result = curl_exec($ch); 109 | 110 | if ($result === FALSE && empty($opts[CURLOPT_IPRESOLVE])) { 111 | $matches = array(); 112 | $regex = '/Failed to connect to ([^:].*): Network is unreachable/'; 113 | 114 | if (preg_match($regex, curl_error($ch), $matches)) { 115 | if (strlen(@inet_pton($matches[1])) === 16) { 116 | custom_error_log('Invalid IPv6 configuration on server, ' . 117 | 'Please disable or get native IPv6 on your server.'); 118 | self::$_CURL_OPTS[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4; 119 | curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); 120 | $result = curl_exec($ch); 121 | } 122 | } 123 | } 124 | 125 | if ($result === FALSE) { 126 | $err = new \Exception(implode("\n", array( 127 | 'error_code' => curl_errno($ch), 128 | 'message' => curl_error($ch) 129 | ))); 130 | 131 | curl_close($ch); 132 | 133 | throw $err; 134 | } 135 | 136 | curl_close($ch); 137 | 138 | if ($data_type === 'json') { 139 | $result = json_decode($result, TRUE); 140 | } 141 | 142 | if ($data_type === 'xml') { 143 | $result = json_decode(json_encode(simplexml_load_string($result)), TRUE); 144 | } 145 | 146 | return $result; 147 | } 148 | 149 | /** 150 | * Log data 151 | * @param mixed $msg 152 | */ 153 | function custom_error_log($msg) { 154 | if (php_sapi_name() != 'cli') { 155 | error_log($msg); 156 | } 157 | } 158 | 159 | /** 160 | * GET request 161 | * @param string $url 162 | * @param array $params 163 | * @return mixed Response data 164 | */ 165 | public static function get($url, $params = array(), $cn = NULL) { 166 | return self::create_request($url, $params, 'GET', $cn); 167 | } 168 | 169 | /** 170 | * POST request 171 | * @param string $url 172 | * @param array $params 173 | * @return mixed Response data 174 | */ 175 | public static function post($url, $params = array(), $cn = NULL) { 176 | return self::create_request($url, $params, 'POST', $cn); 177 | } 178 | 179 | /** 180 | * PUT request 181 | * @param string $url 182 | * @param array $params 183 | * @return mixed Response data 184 | */ 185 | public static function put($url, $params = array(), $cn = NULL) { 186 | return self::create_request($url, $params, 'PUT', $cn); 187 | } 188 | 189 | /** 190 | * DELETE request 191 | * @param string $url 192 | * @param array $params 193 | * @return mixed Response data 194 | */ 195 | public static function delete($url, $params = array(), $cn = NULL) { 196 | return self::create_request($url, $params, 'DELETE', $cn); 197 | } 198 | 199 | } 200 | -------------------------------------------------------------------------------- /application/libraries/MyOAuth2.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | class MyOAuth2 { 16 | 17 | /** 18 | * Create authentication server 19 | * @param array $config 20 | */ 21 | function __construct($config) { 22 | if (!class_exists('OAuth2\Autoloader')) { 23 | require_once APP_VENDOR . DS . 'bshaffer/oauth2-server-php/src/OAuth2/Autoloader.php'; 24 | OAuth2\Autoloader::register(); 25 | } 26 | 27 | if (empty($config)) { 28 | die('OAuth2 Storage settings is not defined'); 29 | } 30 | 31 | $this->storage = new OAuth2\Storage\Pdo(array( 32 | 'dsn' => $config['dsn'], 33 | 'username' => $config['username'], 34 | 'password' => $config['password'] 35 | )); 36 | $this->server = new OAuth2\Server($this->storage, array('allow_implicit' => TRUE)); 37 | $this->request = OAuth2\Request::createFromGlobals(); 38 | $this->response = new OAuth2\Response(); 39 | } 40 | 41 | /** 42 | * Return OAuth2\Server 43 | * @return OAuth2\Server 44 | */ 45 | function server() { 46 | return $this->server; 47 | } 48 | 49 | /** 50 | * Get access_token data by access_token 51 | * @param string $access_token 52 | * @return array 53 | */ 54 | function get_access_token($access_token) { 55 | return $this->storage->getAccessToken($access_token); 56 | } 57 | 58 | /** 59 | * Get client details by client_id 60 | * @param string $client_id 61 | * @return array 62 | */ 63 | function get_client_details($client_id) { 64 | return $this->storage->getClientDetails($client_id); 65 | } 66 | 67 | /** 68 | * Get client details by access_token 69 | * @param string $access_token 70 | * @return array 71 | */ 72 | function get_client_details_by_access_token($access_token) { 73 | $client_data = NULL; 74 | $access_token_details = $this->get_access_token($access_token); 75 | 76 | if (!empty($access_token_details)) { 77 | $client_id = $access_token_details['client_id']; 78 | $client_data = $this->get_client_details($client_id); 79 | } 80 | 81 | return $client_data; 82 | } 83 | 84 | /** 85 | * Get Client details data by incoming request 86 | * @return array 87 | */ 88 | function get_client_details_by_request() { 89 | $headers = $this->request->headers; 90 | $access_token = NULL; 91 | $client_data = NULL; 92 | 93 | if (!empty($headers) && isset($headers['AUTHORIZATION'])) { 94 | $access_token = trim(str_replace('Bearer ', '', $headers['AUTHORIZATION'])); 95 | } else { 96 | $query = $this->request->query; 97 | 98 | if (!empty($query) && isset($query['access_token'])) { 99 | $access_token = trim($query['access_token']); 100 | } 101 | } 102 | 103 | if (!empty($access_token)) { 104 | $client_data = $this->get_client_details_by_access_token($access_token); 105 | } 106 | 107 | return $client_data; 108 | } 109 | 110 | /** 111 | * Authentication for resources 112 | * http://bshaffer.github.io/oauth2-server-php-docs/controllers/resource/ 113 | * 114 | * @param string $format Data format 115 | */ 116 | function authentication_resource($format) { 117 | if (!$this->server->verifyResourceRequest(OAuth2\Request::createFromGlobals())) { 118 | $response = $this->server->getResponse(); 119 | $response->setParameters(array( 120 | 'message' => 'Requires authentication' 121 | )); 122 | $response->send($format); 123 | exit; 124 | } 125 | } 126 | 127 | /** 128 | * The client uses their credentials to retrieve an access token directly, 129 | * which allows access to resources under the client’s control. 130 | * http://bshaffer.github.io/oauth2-server-php-docs/grant-types/client-credentials/ 131 | */ 132 | public function client_credentials($format) { 133 | $this->request->request['grant_type'] = 'client_credentials'; 134 | $this->server->addGrantType(new OAuth2\GrantType\ClientCredentials($this->storage, array( 135 | 'allow_credentials_in_request_body' => FALSE 136 | ))); 137 | $this->server->handleTokenRequest($this->request)->send($format); 138 | } 139 | 140 | /** 141 | * A Resource Owner’s username and password are submitted as part of 142 | * the request, and a token is issued upon successful authentication. 143 | * http://bshaffer.github.io/oauth2-server-php-docs/grant-types/user-credentials/ 144 | */ 145 | public function password_credentials() { 146 | $users = array('user' => array('password' => '1234', 'first_name' => 'John', 'last_name' => 'Doe')); 147 | $storage = new OAuth2\Storage\Memory(array('user_credentials' => $users)); 148 | $this->server->addGrantType(new OAuth2\GrantType\UserCredentials($storage)); 149 | $this->server->handleTokenRequest($this->request)->send(); 150 | } 151 | 152 | /** 153 | * The client can submit a refresh token and recieve 154 | * a new access token if the access token had expired. 155 | * http://bshaffer.github.io/oauth2-server-php-docs/grant-types/refresh-token/ 156 | */ 157 | public function refresh_token() { 158 | $this->server->addGrantType(new \OAuth2\GrantType\RefreshToken($this->storage, array( 159 | 'always_issue_new_refresh_token' => TRUE, 160 | 'unset_refresh_token_after_use' => TRUE, 161 | 'refresh_token_lifetime' => 2419200, 162 | ))); 163 | $this->server->handleTokenRequest($this->request)->send(); 164 | } 165 | 166 | /** 167 | * Limit scpoe here 168 | * @param $scope = "node file userinfo" 169 | */ 170 | public function require_scope($scope = '') { 171 | if (!$this->server->verifyResourceRequest($this->request, $this->response, $scope)) { 172 | $this->server->getResponse()->send(); 173 | exit; 174 | } 175 | } 176 | 177 | public function check_client_id() { 178 | if (!$this->server->validateAuthorizeRequest($this->request, $this->response)) { 179 | $this->response->send(); 180 | exit; 181 | } 182 | } 183 | 184 | public function authorize($is_authorized) { 185 | $this->server->addGrantType(new OAuth2\GrantType\AuthorizationCode($this->storage)); 186 | $this->server->handleAuthorizeRequest($this->request, $this->response, $is_authorized); 187 | if ($is_authorized) { 188 | $code = substr($this->response->getHttpHeader('Location'), strpos($this->response->getHttpHeader('Location'), 'code=') + 5, 40); 189 | header("Location: " . $this->response->getHttpHeader('Location')); 190 | } 191 | $this->response->send(); 192 | } 193 | 194 | public function authorization_code() { 195 | $this->server->addGrantType(new OAuth2\GrantType\AuthorizationCode($this->storage)); 196 | $this->server->handleTokenRequest($this->request)->send(); 197 | } 198 | 199 | } 200 | -------------------------------------------------------------------------------- /application/libraries/RESTful.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | class RESTful { 15 | 16 | protected $request; 17 | protected $response; 18 | protected $oauth; 19 | private $_supported_formats = array( 20 | 'json' => 'application/json', 21 | 'xml' => 'application/xml' 22 | ); 23 | 24 | function __construct($params) { 25 | $this->load = $params['load']; 26 | $this->input = $params['input']; 27 | $this->router = $params['router']; 28 | $this->request = $params['request']; 29 | $this->response = $params['response']; 30 | 31 | $this->process_restful_request(); 32 | } 33 | 34 | /** 35 | * Process incoming RESTful request 36 | */ 37 | private function process_restful_request() { 38 | $method = $this->validate_restful_method(); 39 | 40 | if ($method) { 41 | $format = $this->get_content_type_format(); 42 | $uri_format = NULL; 43 | 44 | if (!$format) { 45 | $format = 'json'; 46 | $uri_format = $this->get_content_type_query_format(); 47 | } 48 | 49 | if ($uri_format) { 50 | $format = $uri_format; 51 | } 52 | 53 | $this->response->set_default_format($format); 54 | 55 | $this->process_api_request(); 56 | 57 | if ($this->request->method() !== $method) { 58 | $this->response->method_not_allowed(); 59 | $this->response->send(array( 60 | 'message' => 'Method not allowed.' 61 | )); 62 | } 63 | } 64 | } 65 | 66 | /** 67 | * Process incoming API request 68 | */ 69 | private function process_api_request() { 70 | if ($this->validate_api_class()) { 71 | if (!defined('RESTFUL_API_KEY')) { 72 | $this->response->unauthorized(); 73 | $this->response->send(array( 74 | 'message' => 'API key is not exists.' 75 | )); 76 | } 77 | 78 | if (!$this->is_valid_api_key()) { 79 | $this->response->unauthorized(); 80 | $this->response->send(array( 81 | 'message' => 'API key is not valid.' 82 | )); 83 | } 84 | 85 | $this->oauth_api_processing(); 86 | } 87 | } 88 | 89 | /** 90 | * Checks if API-KEY is valid 91 | * @return bool 92 | */ 93 | private function is_valid_api_key() { 94 | $api_key = $this->input->server('HTTP_API_KEY'); 95 | return ($api_key === RESTFUL_API_KEY); 96 | } 97 | 98 | /** 99 | * Validate if incoming function is a valid RESTful method. 100 | * @return string | NULL 101 | */ 102 | function validate_restful_method() { 103 | $match = array(); 104 | $method = $this->router->fetch_method(); 105 | $request_method = NULL; 106 | 107 | preg_match('/(.+)\_(get|post|put|delete)$/', $method, $match); 108 | 109 | if (!empty($match)) { 110 | $request_method = $match[2]; 111 | } 112 | 113 | return $request_method; 114 | } 115 | 116 | /** 117 | * Validate if incoming controller is a valid API Controller. 118 | * @return string | NULL 119 | */ 120 | function validate_api_class() { 121 | $match = array(); 122 | $class = $this->router->fetch_class(); 123 | $request_method = NULL; 124 | 125 | preg_match('/(.+)\_(api\_controller)$/', $class, $match); 126 | 127 | if (!empty($match)) { 128 | $request_method = $match[2]; 129 | } 130 | 131 | return $request_method; 132 | } 133 | 134 | /** 135 | * Get the format value in query string. 136 | * @return string | NULL 137 | */ 138 | function get_content_type_query_format() { 139 | $format = NULL; 140 | $uri_format = trim($this->request->get('format')); 141 | $query_format = filter_var($uri_format, FILTER_SANITIZE_STRING); 142 | 143 | if (!empty($query_format) && array_key_exists($query_format, $this->_supported_formats)) { 144 | $format = $query_format; 145 | } 146 | 147 | return $format; 148 | } 149 | 150 | /** 151 | * Get incoming Content-Type value in header. 152 | * @return string | NULL 153 | */ 154 | private function get_content_type_format() { 155 | $content_type = $this->input->server('HTTP_ACCEPT'); 156 | 157 | foreach ($this->_supported_formats as $key => $value) { 158 | if (strpos($content_type, ';') !== FALSE) { 159 | $content_type = current(explode(';', $content_type)); 160 | } 161 | 162 | if ($content_type === $value) { 163 | return $key; 164 | } 165 | } 166 | 167 | return NULL; 168 | } 169 | 170 | /** 171 | * OAuth2 API processing request 172 | */ 173 | private function oauth_api_processing() { 174 | require APP_LIBRARIES . DS . 'MyOAuth2.php'; 175 | 176 | $config = $this->load->config('oauth2', TRUE); 177 | $config_storage = $config['storage']; 178 | $config_ignore = $config['ignore']; 179 | 180 | $this->oauth = new MyOAuth2($config_storage); 181 | 182 | $class_name = $this->router->fetch_class(); 183 | $method_name = $this->router->fetch_method(); 184 | 185 | if (empty($config_ignore) || !in_array("$class_name/$method_name", $config_ignore)) { 186 | $format = $this->response->get_default_format(); 187 | $this->oauth->authentication_resource($format); 188 | } 189 | } 190 | 191 | /** 192 | * Return MyOAuth2 instance 193 | * @return MyOAuth2 194 | */ 195 | function get_oauth() { 196 | return $this->oauth; 197 | } 198 | 199 | } 200 | -------------------------------------------------------------------------------- /application/libraries/Request.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class Request { 11 | 12 | protected $load; 13 | protected $input; 14 | 15 | public function __construct($params) { 16 | $this->load = $params['load']; 17 | $this->input = $params['input']; 18 | } 19 | 20 | /** 21 | * Returns GET data 22 | * @param string $key 23 | * @return mixed 24 | */ 25 | function get($key = NULL) { 26 | return $this->request_data('get', $key); 27 | } 28 | 29 | /** 30 | * Returns POST data 31 | * @param string $key 32 | * @return mixed 33 | */ 34 | function post($key = NULL) { 35 | return $this->request_data('post', $key); 36 | } 37 | 38 | /** 39 | * Returns PUT data 40 | * @param string $key 41 | * @return mixed 42 | */ 43 | function put($key = NULL) { 44 | return $this->request_data('put', $key); 45 | } 46 | 47 | /** 48 | * Returns DELETE data 49 | * @param string $key 50 | * @return mixed 51 | */ 52 | function delete($key = NULL) { 53 | return $this->request_data('delete', $key); 54 | } 55 | 56 | /** 57 | * If GET request 58 | * @return bool 59 | */ 60 | function is_get() { 61 | return ($this->method() === 'get'); 62 | } 63 | 64 | /** 65 | * If POST request 66 | * @return bool 67 | */ 68 | function is_post() { 69 | return ($this->method() === 'post'); 70 | } 71 | 72 | /** 73 | * If PUT request 74 | * @return bool 75 | */ 76 | function is_put() { 77 | return ($this->method() === 'put'); 78 | } 79 | 80 | /** 81 | * If DELETE request 82 | * @return bool 83 | */ 84 | function is_delete() { 85 | return ($this->method() === 'delete'); 86 | } 87 | 88 | /** 89 | * Get HTTP data by specific methods 90 | * @param string $method GET, POST, PUT and DELETE 91 | * @param mixed $key 92 | * @return mixed 93 | */ 94 | private function request_data($method, $key = NULL) { 95 | $values = NULL; 96 | 97 | switch ($method) { 98 | case 'get': 99 | if ($this->is_get()) { 100 | $values = $this->input->get($key); 101 | } 102 | 103 | break; 104 | case 'post': 105 | if ($this->is_post()) { 106 | $values = $this->input->post($key); 107 | } 108 | 109 | break; 110 | case 'put': 111 | if ($this->is_put()) { 112 | $values = $this->raw_request_data($key); 113 | break; 114 | } 115 | 116 | break; 117 | case 'delete': 118 | if ($this->is_delete()) { 119 | $values = $this->raw_request_data($key); 120 | } 121 | 122 | break; 123 | } 124 | 125 | return $values; 126 | } 127 | 128 | /** 129 | * Get raw request data 130 | * @param mixed $key 131 | * @return mixed 132 | */ 133 | private function raw_request_data($key) { 134 | $values = $this->parse_raw_http_request(); 135 | 136 | if (!empty($key)) { 137 | $values = isset($values[$key]) ? $values[$key] : NULL; 138 | } 139 | 140 | return $values; 141 | } 142 | 143 | /** 144 | * Parse raw HTTP request data 145 | * http://www.chlab.ch/blog/archives/php/manually-parse-raw-http-data-php 146 | * 147 | * Pass in $a_data as an array. This is done by reference to avoid copying 148 | * the data around too much. 149 | * 150 | * Any files found in the request will be added by their field name to the 151 | * $data['files'] array. 152 | * 153 | * @param array Empty array to fill with data 154 | * @return array Associative array of request data 155 | */ 156 | function parse_raw_http_request() { 157 | $a_data = array(); 158 | // read incoming data 159 | $input = file_get_contents('php://input'); 160 | 161 | $matches = array(); 162 | // grab multipart boundary from content type header 163 | preg_match('/boundary=(.*)$/', $this->input->server('CONTENT_TYPE'), $matches); 164 | 165 | // content type is probably regular form-encoded 166 | if (!count($matches)) { 167 | // we expect regular puts to containt a query string containing data 168 | parse_str(urldecode($input), $a_data); 169 | return $a_data; 170 | } 171 | 172 | $boundary = $matches[1]; 173 | 174 | // split content by boundary and get rid of last -- element 175 | $a_blocks = preg_split("/-+$boundary/", $input); 176 | array_pop($a_blocks); 177 | 178 | // loop data blocks 179 | foreach ($a_blocks as $block) { 180 | if (empty($block)) { 181 | continue; 182 | } 183 | 184 | // you'll have to var_dump $block to understand this and maybe replace \n or \r with a visibile char 185 | // parse uploaded files 186 | if (strpos($block, 'application/octet-stream') !== FALSE) { 187 | // match "name", then everything after "stream" (optional) except for prepending newlines 188 | preg_match("/name=\"([^\"]*)\".*stream[\n|\r]+([^\n\r].*)?$/s", $block, $matches); 189 | $a_data['files'][$matches[1]] = $matches[2]; 190 | } 191 | // parse all other fields 192 | else { 193 | if (strpos($block, 'filename') !== FALSE) { 194 | $mime = array(); 195 | // match "name" and optional value in between newline sequences 196 | preg_match('/name=\"([^\"]*)\"; filename=\"([^\"]*)\"[\n|\r]+([^\n\r].*)?\r$/s', $block, $matches); 197 | preg_match('/Content-Type: (.*)?/', $matches[3], $mime); 198 | 199 | // match the mime type supplied from the browser 200 | $image = preg_replace('/Content-Type: (.*)[^\n\r]/', '', $matches[3]); 201 | 202 | // get current system path and create tempory file name & path 203 | $path = sys_get_temp_dir() . '/php' . substr(sha1(rand()), 0, 6); 204 | 205 | // write temporary file to emulate $_FILES super global 206 | $err = file_put_contents($path, $image); 207 | 208 | $tmp = array(); 209 | // Did the user use the infamous <input name="array[]" for multiple file uploads? 210 | if (preg_match('/^(.*)\[\]$/i', $matches[1], $tmp)) { 211 | $a_data[$tmp[1]]['name'][] = $matches[2]; 212 | } else { 213 | $a_data[$matches[1]]['name'][] = $matches[2]; 214 | } 215 | 216 | // Create the remainder of the $_FILES super global 217 | $a_data[$tmp[1]]['type'][] = $mime[1]; 218 | $a_data[$tmp[1]]['tmp_name'][] = $path; 219 | $a_data[$tmp[1]]['error'][] = ($err === FALSE) ? $err : 0; 220 | $a_data[$tmp[1]]['size'][] = filesize($path); 221 | } else { 222 | // match "name" and optional value in between newline sequences 223 | preg_match('/name=\"([^\"]*)\"[\n|\r]+([^\n\r].*)?\r$/s', $block, $matches); 224 | 225 | if (preg_match('/^(.*)\[\]$/i', $matches[1], $tmp)) { 226 | $a_data[$tmp[1]][] = $matches[2]; 227 | } else { 228 | $a_data[$matches[1]] = $matches[2]; 229 | } 230 | } 231 | } 232 | } 233 | 234 | return $a_data; 235 | } 236 | 237 | /** 238 | * Get REQUEST_METHOD like GET, PUT, POST, DELETE, PATCH, etc. 239 | * @return string 240 | */ 241 | function method() { 242 | return strtolower($this->input->server('REQUEST_METHOD')); 243 | } 244 | 245 | } 246 | -------------------------------------------------------------------------------- /application/libraries/Response.php: -------------------------------------------------------------------------------- 1 | 9 | */ 10 | class Response { 11 | 12 | private $_default_format = 'json'; 13 | 14 | /** 15 | * JSON format response 16 | * @param mixed $data 17 | */ 18 | function json($data) { 19 | $json = json_encode($data); 20 | 21 | if ($json === FALSE) { 22 | $json = json_encode(array('jsonError', json_last_error_msg())); 23 | 24 | if ($json === FALSE) { 25 | $json = '{"jsonError": "unknown"}'; 26 | } 27 | } 28 | 29 | header('Content-Type: application/json; charset=utf-8'); 30 | echo $json; 31 | } 32 | 33 | /** 34 | * XML format response 35 | * @param mixed $data 36 | */ 37 | function xml($data) { 38 | header('Content-Type: application/xml; charset=utf-8'); 39 | echo $this->to_xml($data); 40 | } 41 | 42 | function to_xml($data, $basenode = 'response', $xml = null) { 43 | // turn off compatibility mode as simple xml throws a wobbly if you don't. 44 | if (ini_get('zend.ze1_compatibility_mode') == 1) { 45 | ini_set('zend.ze1_compatibility_mode', 0); 46 | } 47 | 48 | if ($xml == null) { 49 | $xml = simplexml_load_string("<$basenode />"); 50 | } 51 | 52 | // loop through the data passed in. 53 | foreach ($data as $key => $value) { 54 | // no numeric keys in our xml please! 55 | if (is_numeric($key)) { 56 | // make string key... 57 | $key = "item_" . (string) $key; 58 | } 59 | 60 | // replace anything not alpha numeric 61 | $key = preg_replace('/[^a-z]/i', '', $key); 62 | 63 | // if there is another array found recrusively call this function 64 | if (is_array($value)) { 65 | $node = $xml->addChild($key); 66 | // recrusive call. 67 | $this->to_xml($value, $basenode, $node); 68 | } else { 69 | // add single node. 70 | $value = htmlentities($value); 71 | $xml->addChild($key, $value); 72 | } 73 | } 74 | // pass back as string. or simple xml object if you want! 75 | return $xml->asXML(); 76 | } 77 | 78 | /** 79 | * Send data by default format 80 | * @param array $data 81 | */ 82 | function send($data) { 83 | $this->{$this->_default_format}($data); 84 | exit; 85 | } 86 | 87 | /** 88 | * Set the default output format 89 | * @param string $format json, xml and html 90 | * @param string $format 91 | */ 92 | function set_default_format($format) { 93 | $this->_default_format = $format; 94 | } 95 | 96 | /** 97 | * Get the default output format 98 | * @param string $format 99 | */ 100 | function get_default_format() { 101 | return $this->_default_format; 102 | } 103 | 104 | function forbidden() { 105 | $this->status(403, 'HTTP/1.1 403 Forbidden'); 106 | } 107 | 108 | function not_found() { 109 | $this->status(404, 'HTTP/1.1 404 Not Found'); 110 | } 111 | 112 | function ok() { 113 | $this->status(200, 'HTTP/1.1 200 OK'); 114 | } 115 | 116 | function bad_request() { 117 | $this->status(400, 'HTTP/1.1 400 Bad Request'); 118 | } 119 | 120 | function method_not_allowed() { 121 | $this->status(405, 'HTTP/1.1 405 Method Not Allowed'); 122 | } 123 | 124 | function service_unavailable() { 125 | $this->status(503, 'HTTP/1.1 503 Service Unavailable'); 126 | } 127 | 128 | function internal_server_error() { 129 | $this->status(500, 'HTTP/1.1 500 Internal Server Error'); 130 | } 131 | 132 | function unauthorized() { 133 | $this->status(401, 'HTTP/1.1 401 Unauthorized'); 134 | } 135 | 136 | function request_timeout() { 137 | $this->status(408, 'HTTP/1.1 408 Request Timeout'); 138 | } 139 | 140 | private function status($code, $msg = '') { 141 | header($msg, TRUE, $code); 142 | } 143 | 144 | } 145 | -------------------------------------------------------------------------------- /application/libraries/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/logs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/models/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/models/welcome_model.php: -------------------------------------------------------------------------------- 1 | response->get_default_format(); 19 | $this->oauth->client_credentials($format); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /application/modules/oauth2/controllers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/modules/user/config/routes.php: -------------------------------------------------------------------------------- 1 | load->model('User_model'); 16 | } 17 | 18 | /** 19 | * Get one specific user by id. 20 | * GET /v1/user/[:id] 21 | * @param int $id 22 | */ 23 | function one_get($id) { 24 | $user = $this->User_model->find_one_by_id($id); 25 | $this->response->send($user); 26 | } 27 | 28 | /** 29 | * Get all users. 30 | * GET /v1/user 31 | */ 32 | function all_get() { 33 | $users = $this->User_model->find_all(); 34 | $this->response->send($users); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /application/modules/user/controllers/User_controller.php: -------------------------------------------------------------------------------- 1 | 17 | * 18 | * @see http://codeigniter.com/user_guide/general/urls.html 19 | */ 20 | function index_get() { 21 | $this->load->model('User_model'); 22 | 23 | $users = $this->User_model->find_all(); 24 | $this->response->output($users); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /application/modules/user/controllers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/modules/user/models/User_model.php: -------------------------------------------------------------------------------- 1 | find()->toArray(); 20 | } catch (PropelException $e) { 21 | return; 22 | } 23 | } 24 | 25 | /** 26 | * Find one user by primary key 27 | * @return array 28 | */ 29 | function find_one_by_id($id) { 30 | try { 31 | $data = array(); 32 | $user = UserQuery::create()->findPk($id); 33 | 34 | if ($user) { 35 | $data = $user->toArray(); 36 | } 37 | 38 | return $data; 39 | } catch (PropelException $e) { 40 | return; 41 | } 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /application/modules/user/views/User_view.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 |83 | application/modules 84 | │ 85 | └── user 86 | ├── config 87 | │ └── routes.php 88 | ├── controllers 89 | │ └── User_controller.php 90 | ├── models 91 | │ └── User_model.php 92 | └── views 93 | └── User_message.php 94 |95 | 96 |
99 | // User_controller.php 100 | $this->User_model->find_all(); 101 |102 | Records from database: 103 | 104 |
Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/views/errors/cli/error_404.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 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/views/errors/html/error_404.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 |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 |
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 |
Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/views/errors/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Directory access is forbidden.
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /application/views/welcome_message.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 |
78 | The page you are looking at is being generated dynamically by CodeIgniter.
79 | If you would like to edit this page you'll find it located at:
80 |
application/views/welcome_message.php
83 |
84 | The corresponding controller for this page is found at:
85 |application/controllers/Welcome.php
86 |
87 |
88 |
89 | If you are exploring CodeIgniter for the very first time, you should start by reading the User Guide.
90 |