index.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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-2023
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J. Crane <[email protected]>
  20. */
  21. //start the session
  22. ini_set("session.cookie_httponly", True);
  23. if (!isset($_SESSION)) { session_start(); }
  24. //includes files
  25. require_once __DIR__ . "/resources/require.php";
  26. //if logged in, redirect to login destination
  27. if (isset($_SESSION["username"])) {
  28. if (isset($_SESSION['login']['destination']['text'])) {
  29. header("Location: ".$_SESSION['login']['destination']['text']);
  30. }
  31. elseif (file_exists($_SERVER["PROJECT_ROOT"]."/core/dashboard/app_config.php")) {
  32. header("Location: ".PROJECT_PATH."/core/dashboard/");
  33. }
  34. else {
  35. require_once "resources/header.php";
  36. require_once "resources/footer.php";
  37. }
  38. }
  39. else {
  40. //use custom index, if present, otherwise use custom login, if present, otherwise use default login
  41. if (file_exists($_SERVER["PROJECT_ROOT"]."/themes/".($_SESSION['domain']['template']['name'] ?? '')."/index.php")) {
  42. require_once "themes/".$_SESSION['domain']['template']['name']."/index.php";
  43. }
  44. else {
  45. //login prompt
  46. header("Location: ".PROJECT_PATH."/login.php");
  47. }
  48. }
  49. ?>