require.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2012
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //ensure that $_SERVER["DOCUMENT_ROOT"] is defined
  22. include "root.php";
  23. //find and include the config.php file
  24. $config_exists = false;
  25. if (file_exists("/etc/fusionpbx/config.php")) {
  26. $config_exists = true;
  27. include "/etc/fusionpbx/config.php";
  28. }
  29. elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) {
  30. $config_exists = true;
  31. include "/usr/local/etc/fusionpbx/config.php";
  32. }
  33. elseif (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/config.php")) {
  34. $config_exists = true;
  35. include "resources/config.php";
  36. }
  37. //class auto loader
  38. if (!class_exists('auto_loader')) {
  39. class auto_loader {
  40. public function __construct() {
  41. spl_autoload_register(array($this, 'loader'));
  42. }
  43. private function loader($class_name) {
  44. //use glob to get classes (note: GLOB_BRACE doesn't work on some systems)
  45. $results_1 = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/resources/classes/".$class_name.".php");
  46. $results_2 = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/resources/classes/".$class_name.".php");
  47. $results = array_merge((array)$results_1,(array)$results_2);
  48. unset($results_1, $results_2);
  49. //include the class
  50. foreach ($results as &$class_file) {
  51. if (!class_exists($class_name)) {
  52. include $class_file;
  53. }
  54. }
  55. unset($results);
  56. }
  57. }
  58. }
  59. $autoload = new auto_loader();
  60. //define variable(s)
  61. $default_login = false; //used in the themes
  62. //additional includes
  63. require_once "resources/php.php";
  64. require_once "resources/functions.php";
  65. if ($config_exists) {
  66. require "resources/pdo.php";
  67. }
  68. //change language on the fly - for translate tool (if available)
  69. if (isset($_REQUEST['view_lang_code']) && ($_REQUEST['view_lang_code']) != '') {
  70. $_SESSION['domain']['language']['code'] = $_REQUEST['view_lang_code'];
  71. }
  72. ?>