PageRenderTime 66ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/core/run.php

https://github.com/wilkerlucio/fishy-framework
PHP | 80 lines | 20 code | 12 blank | 48 comment | 0 complexity | 6d9d7770a8a67b6f891741c202b2d578 MD5 | raw file
  1. <?php
  2. /*
  3. * Copyright 2008 Wilker Lucio <wilkerlucio@gmail.com>
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. //set some system definitios
  18. define('FISHY_SYSTEM_CLASS_PREFIX', 'Fishy_');
  19. //load core exceptions
  20. require_once FISHY_SYSTEM_CORE_PATH . '/core_exceptions.php';
  21. //some simple usefull helpers functions
  22. require_once FISHY_SYSTEM_CORE_PATH . '/core_helpers.php';
  23. //autoloader for classes
  24. include_once FISHY_SYSTEM_CORE_PATH . '/autoloader.php';
  25. //load uri
  26. $current_uri = Fishy_Uri::get_querystring();
  27. //load configuration basics
  28. $conf = include FISHY_CONFIG_PATH . '/config.php';
  29. define('FISHY_BASE_URL', $conf->base_url);
  30. define('FISHY_INDEX_PAGE', $conf->index_page);
  31. //load router configuration
  32. $router_conf = require_once FISHY_CONFIG_PATH . '/router.php';
  33. $ROUTER = new UserRouter();
  34. //load slice routes
  35. foreach (glob(FISHY_SLICES_PATH . "/*/config/router.php") as $router) {
  36. include_once $router;
  37. }
  38. try {
  39. $current_route = $ROUTER->match($current_uri);
  40. } catch (Fishy_RouterException $e) {
  41. dispatch_error($e, 404);
  42. }
  43. //disable magic quotes
  44. include_once FISHY_SYSTEM_CORE_PATH . '/magic_quotes.php';
  45. //transform upload format
  46. include_once FISHY_SYSTEM_CORE_PATH . '/upload_transform.php';
  47. //load database
  48. require_once FISHY_SYSTEM_DATABASE_PATH . '/ActiveRecord.php';
  49. $db_conf = include FISHY_CONFIG_PATH . '/db.php';
  50. FieldAct::set_upload_path(FISHY_UPLOAD_PATH . '/');
  51. DBCommand::configure($db_conf->host, $db_conf->user, $db_conf->password, $db_conf->database);
  52. //if your submodules needs to do something, this is the time!
  53. foreach (glob(FISHY_SLICES_PATH . "/*/config/setup.php") as $setup) {
  54. include_once $setup;
  55. }
  56. //run!
  57. try {
  58. Fishy_Controller::run($current_route);
  59. } catch (Exception $e) {
  60. dispatch_error($e);
  61. }