Fork of FusionPBX but with LDAP kinda working
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.8 KiB

2 years ago
  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 <markjcrane@fusionpbx.com>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2021
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J. Crane <markjcrane@fusionpbx.com>
  20. */
  21. //include root
  22. include "root.php";
  23. //start the session
  24. ini_set("session.cookie_httponly", True);
  25. if (!isset($_SESSION)) { session_start(); }
  26. //if config.php file does not exist then redirect to the install page
  27. if (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) {
  28. //do nothing
  29. } elseif (file_exists($_SERVER["PROJECT_ROOT"]."/resources/config.php")) {
  30. //original directory
  31. } elseif (file_exists($_SERVER["PROJECT_ROOT"]."/includes/config.php")) {
  32. //move config.php from the includes to resources directory.
  33. rename($_SERVER["PROJECT_ROOT"]."/includes/config.php", $_SERVER["PROJECT_ROOT"]."/resources/config.php");
  34. } elseif (file_exists("/etc/fusionpbx/config.php")) {
  35. //linux
  36. } elseif (file_exists("/usr/local/etc/fusionpbx/config.php")) {
  37. //bsd
  38. } else {
  39. header("Location: ".PROJECT_PATH."/core/install/install.php");
  40. exit;
  41. }
  42. //if not logged in, clear the session variables
  43. //if (strlen($_SESSION["username"]) == 0) {
  44. // session_unset();
  45. // session_destroy();
  46. //}
  47. //adds multiple includes
  48. require_once "resources/require.php";
  49. //if logged in, redirect to login destination
  50. if (isset($_SESSION["username"])) {
  51. if (isset($_SESSION['login']['destination']['url'])) {
  52. header("Location: ".$_SESSION['login']['destination']['url']);
  53. } elseif (file_exists($_SERVER["PROJECT_ROOT"]."/core/dashboard/app_config.php")) {
  54. header("Location: ".PROJECT_PATH."/core/dashboard/");
  55. }
  56. else {
  57. require_once "resources/header.php";
  58. require_once "resources/footer.php";
  59. }
  60. }
  61. else {
  62. //use custom index, if present, otherwise use custom login, if present, otherwise use default login
  63. if (file_exists($_SERVER["PROJECT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/index.php")) {
  64. require_once "themes/".$_SESSION['domain']['template']['name']."/index.php";
  65. } else if (file_exists($_SERVER["PROJECT_ROOT"]."/themes/".$_SESSION['domain']['template']['name']."/login.php")) {
  66. require_once "themes/".$_SESSION['domain']['template']['name']."/login.php";
  67. }
  68. else {
  69. require_once "resources/login.php";
  70. }
  71. }
  72. ?>