footer.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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-2019
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //includes
  22. include "root.php";
  23. require_once "resources/require.php";
  24. //set variables if not set
  25. //if (!isset($_SESSION["template_content"])) { $_SESSION["template_content"] = null; }
  26. if (!isset($document)) { $document = null; }
  27. if (!isset($v_menu)) { $v_menu = null; }
  28. if (!isset($_SESSION["menu"])) { $_SESSION["menu"] = null; }
  29. if (!isset($_SESSION["username"])) { $_SESSION["username"] = null; }
  30. //get the output from the buffer
  31. $body = $content_from_db.ob_get_contents();
  32. ob_end_clean(); //clean the buffer
  33. //clear the template
  34. //if (isset($_SESSION['theme']['cache']['boolean']) && $_SESSION['theme']['cache']['boolean'] == "false") {
  35. // $_SESSION["template_content"] = '';
  36. //}
  37. //set a default template
  38. if (strlen($_SESSION["template_full_path"]) == 0) { //build template if session template has no length
  39. $template_base_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes';
  40. if (strlen($template_rss_sub_category) > 0) {
  41. //this template was assigned by the content manager
  42. //get the contents of the template and save it to the template variable
  43. $template_full_path = $template_base_path.'/'.$template_rss_sub_category.'/template.php';
  44. if (!file_exists($template_full_path)) {
  45. $_SESSION['domain']['template']['name'] = 'default';
  46. $template_full_path = $template_base_path.'/default/template.php';
  47. }
  48. $_SESSION["template_full_path"] = $template_full_path;
  49. }
  50. else {
  51. //get the contents of the template and save it to the template variable
  52. $template_full_path = $template_base_path.'/'.$_SESSION['domain']['template']['name'].'/template.php';
  53. if (!file_exists($template_full_path)) {
  54. $_SESSION['domain']['template']['name'] = 'default';
  55. $template_full_path = $template_base_path.'/default/template.php';
  56. }
  57. $_SESSION["template_full_path"] = $template_full_path;
  58. }
  59. }
  60. //get the template
  61. ob_start();
  62. include($_SESSION["template_full_path"]);
  63. $template = ob_get_contents(); //get the output from the buffer
  64. ob_end_clean(); //clean the buffer
  65. //prepare the template to display the output
  66. $custom_head = '';
  67. if (isset($_SESSION["theme"]["title"]["text"])) {
  68. if (strlen($_SESSION["theme"]["title"]["text"]) > 0) {
  69. $document_title = (($document["title"] != '') ? $document["title"]." - " : null).$_SESSION["theme"]["title"]["text"];
  70. }
  71. else {
  72. $document_title = (($document["title"] != '') ? $document["title"]." " : null);
  73. }
  74. }
  75. else {
  76. if (isset($_SESSION["software_name"])) {
  77. $document_title = (($document["title"] != '') ? $document["title"]." - " : null).$_SESSION["software_name"];
  78. }
  79. else {
  80. $document_title = (($document["title"] != '') ? $document["title"]." " : null);
  81. }
  82. }
  83. $output = str_replace ("<!--{title}-->", $document_title, $template); //<!--{title}--> defined in each individual page
  84. $output = str_replace ("<!--{head}-->", $custom_head, $output); //<!--{head}--> defined in each individual page
  85. if (strlen($v_menu) > 0) {
  86. $output = str_replace ("<!--{menu}-->", $v_menu, $output); //defined in /resources/menu.php
  87. }
  88. else {
  89. $output = str_replace ("<!--{menu}-->", $_SESSION["menu"], $output); //defined in /resources/menu.php
  90. }
  91. $output = str_replace ("<!--{project_path}-->", PROJECT_PATH, $output); //defined in /resources/menu.php
  92. $pos = strrpos($output, "<!--{body}-->");
  93. if ($pos === false) {
  94. $output = $body; //if tag not found just show the body
  95. }
  96. else {
  97. //replace the body
  98. $output = str_replace ("<!--{body}-->", $body, $output);
  99. }
  100. //send the output to the browser
  101. echo $output;
  102. unset($output);
  103. //$statsauth = "a3az349x2bf3fdfa8dbt7x34fas5X";
  104. //require_once "stats/stat_sadd.php";
  105. ?>