header.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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-2020
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //includes files
  22. require_once __DIR__ . "/require.php";
  23. //start the session
  24. ini_set("session.cookie_httponly", true);
  25. if (!isset($_SESSION)) { session_start(); }
  26. //set the domains session
  27. if (!isset($_SESSION['domains'])) {
  28. $domain = new domains();
  29. $domain->session();
  30. $domain->set();
  31. }
  32. //if reloadxml then run the command
  33. if (permission_exists('dialplan_edit') && isset($_SESSION["reload_xml"])) {
  34. if (!empty($_SESSION["reload_xml"])) {
  35. if (isset($_SESSION['apply_settings']) && $_SESSION['apply_settings'] == "true") {
  36. //show the apply settings prompt
  37. }
  38. else {
  39. //reload the access control list this also runs reloadxml
  40. $response = event_socket::api('reloadxml');
  41. $_SESSION["reload_xml"] = '';
  42. unset($_SESSION["reload_xml"]);
  43. usleep(500);
  44. //clear the apply settings reminder
  45. $_SESSION["reload_xml"] = false;
  46. }
  47. }
  48. }
  49. //set the template base directory path
  50. $template_base_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes';
  51. //check if the template exists if it is missing then use the default
  52. if (!file_exists($template_base_path.'/'.$_SESSION['domain']['template']['name'].'/template.php')) {
  53. $_SESSION['domain']['template']['name'] = 'default';
  54. }
  55. //start the output buffer
  56. include $template_base_path.'/'.$_SESSION['domain']['template']['name'].'/config.php';
  57. //start the output buffer
  58. ob_start();
  59. //get the content
  60. if (isset($_GET["c"])) {
  61. $content = $_GET["c"]; //link
  62. }
  63. else {
  64. $content = '';
  65. }
  66. //connect to the database if not initialized
  67. if (!($database instanceof database)) {
  68. $database = new database();
  69. }
  70. //get the parent id
  71. $sql = "select menu_item_parent_uuid from v_menu_items ";
  72. $sql .= "where menu_uuid = :menu_uuid ";
  73. $sql .= "and menu_item_link = :menu_item_link ";
  74. $parameters['menu_uuid'] = $_SESSION['domain']['menu']['uuid'];
  75. $parameters['menu_item_link'] = $_SERVER["SCRIPT_NAME"];
  76. $_SESSION["menu_item_parent_uuid"] = $database->select($sql, $parameters, 'column');
  77. unset($sql, $parameters);
  78. //get the content
  79. if (file_exists($_SERVER["PROJECT_ROOT"]."/app/content/app_config.php")) {
  80. $sql = "select * from v_rss ";
  81. $sql .= "where domain_uuid = :domain_uuid ";
  82. $sql .= "and rss_category = 'content' ";
  83. $sql .= "and rss_link = :content ";
  84. $sql .= "and ( ";
  85. $sql .= "length(rss_del_date) = 0 ";
  86. $sql .= "or rss_del_date is null ";
  87. $sql .= ") ";
  88. $sql .= "order by rss_order asc ";
  89. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  90. $parameters['content'] = empty($content) ? $_SERVER["PHP_SELF"] : $content;
  91. $content_result = $database->select($sql, $parameters, 'all');
  92. if (is_array($content_result) && @sizeof($content_result) != 0) {
  93. foreach($content_result as $content_row) {
  94. $template_rss_sub_category = $content_row['rss_sub_category'];
  95. if (empty($content_row['rss_group'])) {
  96. //content is public
  97. $content_from_db = &$content_row['rss_description'];
  98. if (!empty($content_row['rss_title'])) {
  99. $page["title"] = $content_row['rss_title'];
  100. }
  101. }
  102. else {
  103. if (if_group($content_row[rss_group])) { //viewable only to designated group
  104. $content_from_db = &$content_row[rss_description];
  105. if (!empty($content_row['rss_title'])) {
  106. $page["title"] = $content_row['rss_title'];
  107. }
  108. }
  109. }
  110. }
  111. }
  112. unset($sql, $parameters, $content_result, $content_row);
  113. }
  114. //button css class and styles
  115. $button_icon_class = '';
  116. $button_icon_style = 'padding: 3px;';
  117. $button_label_class = 'button-label';
  118. $button_label_style = 'padding-left: 5px; padding-right: 3px;';
  119. $button_icons = (!empty($_SESSION['theme']['button_icons']['text'])) ? $button_icons = $_SESSION['theme']['button_icons']['text'] : '';
  120. switch ($button_icons) {
  121. case 'auto':
  122. $button_label_class .= ' hide-md-dn';
  123. break;
  124. case 'only':
  125. $button_label_style .= ' display: none;';
  126. break;
  127. case 'never':
  128. $button_icon_class .= ' display: none;';
  129. break;
  130. case 'always':
  131. break;
  132. }
  133. //start the output buffer
  134. ob_start();
  135. //for translate tool (if available)
  136. if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/translate/translate_header.php")) {
  137. require_once("app/translate/translate_header.php");
  138. }
  139. ?>