footer.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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-2022
  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. //set variables if not set
  24. //if (!isset($_SESSION["template_content"])) { $_SESSION["template_content"] = null; }
  25. if (!isset($document)) { $document = null; }
  26. if (!isset($v_menu)) { $v_menu = null; }
  27. if (!isset($_SESSION["menu"])) { $_SESSION["menu"] = null; }
  28. if (!isset($_SESSION["username"])) { $_SESSION["username"] = null; }
  29. //get the output from the buffer
  30. $body = ($content_from_db ?? '').ob_get_contents();
  31. ob_end_clean(); //clean the buffer
  32. //clear the template
  33. //if (isset($_SESSION['theme']['cache']['boolean']) && $_SESSION['theme']['cache']['boolean'] == "false") {
  34. // $_SESSION["template_content"] = '';
  35. //}
  36. //set a default template
  37. if (empty($_SESSION["template_full_path"])) { //build template if session template has no length
  38. $template_base_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes';
  39. if (!empty($template_rss_sub_category)) {
  40. //this template was assigned by the content manager
  41. //get the contents of the template and save it to the template variable
  42. $template_full_path = $template_base_path.'/'.$template_rss_sub_category.'/template.php';
  43. if (!file_exists($template_full_path)) {
  44. $_SESSION['domain']['template']['name'] = 'default';
  45. $template_full_path = $template_base_path.'/default/template.php';
  46. }
  47. $_SESSION["template_full_path"] = $template_full_path;
  48. }
  49. else {
  50. //get the contents of the template and save it to the template variable
  51. $template_full_path = $template_base_path.'/'.$_SESSION['domain']['template']['name'].'/template.php';
  52. if (!file_exists($template_full_path)) {
  53. $_SESSION['domain']['template']['name'] = 'default';
  54. $template_full_path = $template_base_path.'/default/template.php';
  55. }
  56. $_SESSION["template_full_path"] = $template_full_path;
  57. }
  58. }
  59. //initialize a template object
  60. $view = new template();
  61. $view->engine = 'smarty';
  62. $view->template_dir = $_SERVER['DOCUMENT_ROOT'].PROJECT_PATH.'/themes/'.$_SESSION['domain']['template']['name'].'/';
  63. $view->cache_dir = $_SESSION['server']['temp']['dir'] ?: sys_get_temp_dir();
  64. $view->init();
  65. //add multi-lingual support
  66. $language = new text;
  67. $text_default = $language->get();
  68. $text_application = $language->get(null,'themes/'.$_SESSION['domain']['template']['name']);
  69. $text = array_merge($text_default, $text_application);
  70. //create token
  71. $object = new token;
  72. $domain_json_token = $object->create('/core/domains/domain_json.php');
  73. //set the variable
  74. $logo = '';
  75. //set template variables
  76. //add translations
  77. foreach($text as $key => $value) {
  78. $array[str_replace('-', '_', $key)] = $value;
  79. }
  80. $view->assign('text', $array);
  81. //project path
  82. $view->assign('project_path', PROJECT_PATH);
  83. //domain menu
  84. $view->assign('domain_menu', escape($_SESSION['domain']['menu']['uuid']));
  85. //domain json token
  86. $view->assign('domain_json_token_name', $domain_json_token['name']);
  87. $view->assign('domain_json_token_hash', $domain_json_token['hash']);
  88. //theme settings
  89. if (is_array($_SESSION['theme']) && @sizeof($_SESSION['theme']) != 0) {
  90. //load into array
  91. foreach ($_SESSION['theme'] as $subcategory => $setting) {
  92. switch($subcategory) {
  93. //exceptions
  94. case 'favicon':
  95. case 'custom_css':
  96. if ($setting['text'] != '') {
  97. $tmp_url = parse_url($setting['text']);
  98. $tmp_path = pathinfo($setting['text']);
  99. if (
  100. is_array($tmp_url) && @sizeof($tmp_url) != 0 &&
  101. is_array($tmp_path) && @sizeof($tmp_path) != 0 &&
  102. (
  103. (!empty($tmp_url['scheme']) && $tmp_url['scheme'].'://'.$tmp_url['host'].$tmp_url['path'] == $tmp_path['dirname'].'/'.$tmp_path['filename'].'.'.$tmp_path['extension']) //is url
  104. || $tmp_url['path'] == $tmp_path['dirname'].'/'.$tmp_path['filename'].'.'.$tmp_path['extension'] //is path
  105. )) {
  106. $settings_array['theme'][$subcategory] = $setting['text'];
  107. }
  108. unset($tmp_url, $tmp_path);
  109. }
  110. break;
  111. //otherwise
  112. default:
  113. if (isset($setting['text']) && $setting['text'] != '') {
  114. $settings_array['theme'][$subcategory] = str_replace('&lowbar;','_',escape($setting['text']));
  115. }
  116. else if (isset($setting['numeric']) && is_numeric($setting['numeric'])) {
  117. $settings_array['theme'][$subcategory] = $setting['numeric'];
  118. }
  119. else if (isset($setting['boolean'])) {
  120. $settings_array['theme'][$subcategory] = $setting['boolean'] == 'true' ? true : false;
  121. }
  122. else {
  123. $settings_array['theme'][$subcategory] = escape($setting);
  124. }
  125. }
  126. }
  127. //pre-process some settings
  128. $settings_array['theme']['favicon'] = !empty($settings_array['theme']['favicon']) ? $settings_array['theme']['favicon'] : PROJECT_PATH.'/themes/default/favicon.ico';
  129. $settings_array['theme']['font_loader_version'] = !empty($settings_array['theme']['font_loader_version']) ? urlencode($settings_array['theme']['font_loader_version']) : '1';
  130. $settings_array['theme']['message_delay'] = isset($settings_array['theme']['message_delay']) ? 1000 * (float) $settings_array['theme']['message_delay'] : 3000;
  131. $settings_array['theme']['menu_side_width_contracted'] = isset($settings_array['theme']['menu_side_width_contracted']) ? $settings_array['theme']['menu_side_width_contracted'] : '60';
  132. $settings_array['theme']['menu_side_width_expanded'] = isset($settings_array['theme']['menu_side_width_expanded']) ? $settings_array['theme']['menu_side_width_expanded'] : '225';
  133. $settings_array['theme']['menu_side_toggle_hover_delay_expand'] = isset($settings_array['theme']['menu_side_toggle_hover_delay_expand']) ? $settings_array['theme']['menu_side_toggle_hover_delay_expand'] : '300';
  134. $settings_array['theme']['menu_side_toggle_hover_delay_contract'] = isset($settings_array['theme']['menu_side_toggle_hover_delay_contract']) ? $settings_array['theme']['menu_side_toggle_hover_delay_contract'] : '1000';
  135. $settings_array['theme']['menu_style'] = !empty($settings_array['theme']['menu_style']) ? $settings_array['theme']['menu_style'] : 'fixed';
  136. $settings_array['theme']['menu_position'] = isset($settings_array['theme']['menu_position']) ? $settings_array['theme']['menu_position'] : 'top';
  137. $settings_array['theme']['footer'] = isset($settings_array['theme']['footer']) ? $settings_array['theme']['footer'] : '&copy; '.$text['theme-label-copyright'].' 2008 - '.date('Y')." <a href='http://www.fusionpbx.com' class='footer' target='_blank'>fusionpbx.com</a> ".$text['theme-label-all_rights_reserved'];
  138. //assign the setings
  139. $view->assign('settings', $settings_array);
  140. }
  141. //document title
  142. if (isset($_SESSION['theme']['title']['text']) && $_SESSION['theme']['title']['text'] != '') {
  143. $document_title = $_SESSION['theme']['title']['text'];
  144. }
  145. $document_title = (!empty($document['title']) ? $document['title'].' - ' : null).($document_title ?? '');
  146. $view->assign('document_title', $document_title);
  147. //domain selector control
  148. $domain_selector_enabled = permission_exists('domain_select') && count($_SESSION['domains']) > 1 ? true : false;
  149. $view->assign('domain_selector_enabled', $domain_selector_enabled);
  150. //browser name
  151. $user_agent = http_user_agent();
  152. $browser_version = $user_agent['version'];
  153. $view->assign('browser_name', $user_agent['name']);
  154. $view->assign('browser_name_short', $user_agent['name_short']);
  155. //login state
  156. $authenticated = isset($_SESSION['username']) && !empty($_SESSION['username']) ? true : false;
  157. $view->assign('authenticated', $authenticated);
  158. //domains application path
  159. $view->assign('domains_app_path', PROJECT_PATH.(file_exists($_SERVER['DOCUMENT_ROOT'].'/app/domains/domains.php') ? '/app/domains/domains.php' : '/core/domains/domains.php'));
  160. //domain count
  161. $view->assign('domain_count', is_array($_SESSION['domains']) ? sizeof($_SESSION['domains']) : 0);
  162. //domain selector row background colors
  163. $view->assign('domain_selector_background_color_1', !empty($_SESSION['theme']['domain_inactive_background_color'][0]) != '' ? $_SESSION['theme']['domain_inactive_background_color'][0] : '#eaedf2');
  164. $view->assign('domain_selector_background_color_2', !empty($_SESSION['theme']['domain_inactive_background_color'][1]) != '' ? $_SESSION['theme']['domain_inactive_background_color'][1] : '#ffffff');
  165. $view->assign('domain_active_background_color', !empty($_SESSION['theme']['domain_active_background_color']['text']) ? $_SESSION['theme']['domain_active_background_color']['text'] : '#eeffee');
  166. //domain list
  167. $view->assign('domains', $_SESSION['domains']);
  168. //domain uuid
  169. $view->assign('domain_uuid', $_SESSION['domain_uuid']);
  170. //menu container
  171. //load menu array into the session
  172. if (!isset($_SESSION['menu']['array'])) {
  173. $menu = new menu;
  174. $menu->menu_uuid = $_SESSION['domain']['menu']['uuid'];
  175. $_SESSION['menu']['array'] = $menu->menu_array();
  176. unset($menu);
  177. }
  178. //build menu by style
  179. switch ($_SESSION['theme']['menu_style']['text']) {
  180. case 'side':
  181. $view->assign('menu_side_state', (isset($_SESSION['theme']['menu_side_state']['text']) && $_SESSION['theme']['menu_side_state']['text'] != '' ? $_SESSION['theme']['menu_side_state']['text'] : 'expanded'));
  182. if ($_SESSION['theme']['menu_side_state']['text'] != 'hidden') {
  183. $menu_side_toggle = $_SESSION['theme']['menu_side_toggle']['text'] == 'hover' ? " onmouseenter=\"clearTimeout(menu_side_contract_timer); if ($('#menu_side_container').width() < 100) { menu_side_expand_start(); }\" onmouseleave=\"clearTimeout(menu_side_expand_timer); if ($('#menu_side_container').width() > 100 && $('#menu_side_state_current').val() != 'expanded') { menu_side_contract_start(); }\"" : null;
  184. }
  185. $container_open = "<div id='menu_side_container' ".($_SESSION['theme']['menu_side_state']['text'] == 'hidden' ? "style='display: none;'" : "class='hide-xs'").$menu_side_toggle." >\n";
  186. $menu = new menu;
  187. $menu->text = $text;
  188. $menu_html = $menu->menu_vertical($_SESSION['menu']['array']);
  189. unset($menu);
  190. break;
  191. case 'inline':
  192. $container_open = "<div class='container-fluid' style='padding: 0;' align='".($_SESSION['theme']['logo_align']['text'] != '' ? $_SESSION['theme']['logo_align']['text'] : 'left')."'>\n";
  193. if ($_SERVER['PHP_SELF'] != PROJECT_PATH.'/core/install/install.php') {
  194. $logo = "<a href='".PROJECT_PATH."/'><img src='".($_SESSION['theme']['logo']['text'] ?: PROJECT_PATH.'/themes/default/images/logo.png')."' style='padding: 15px 20px; ".($_SESSION['theme']['logo_style']['text'] ?: null)."'></a>";
  195. }
  196. $menu = new menu;
  197. $menu->text = $text;
  198. $menu_html = $menu->menu_horizontal($_SESSION['menu']['array']);
  199. unset($menu);
  200. break;
  201. case 'static':
  202. $container_open = "<div class='container-fluid' style='padding: 0;' align='center'>\n";
  203. $menu = new menu;
  204. $menu->text = $text;
  205. $menu_html = $menu->menu_horizontal($_SESSION['menu']['array']);
  206. unset($menu);
  207. break;
  208. case 'fixed':
  209. default:
  210. $menu = new menu;
  211. $menu->text = $text;
  212. $menu_html = $menu->menu_horizontal($_SESSION['menu']['array']);
  213. unset($menu);
  214. $container_open = "<div class='container-fluid' style='padding: 0;' align='center'>\n";
  215. break;
  216. }
  217. $view->assign('logo', $logo);
  218. $view->assign('menu', $menu_html);
  219. $view->assign('container_open', $container_open);
  220. $view->assign('container_close', '</div>');
  221. $view->assign('document_body', $body);
  222. $view->assign('current_year', date('Y'));
  223. //login logo
  224. //determine logo source
  225. if (isset($_SESSION['theme']['logo_login']['text']) && $_SESSION['theme']['logo_login']['text'] != '') {
  226. $login_logo_source = $_SESSION['theme']['logo_login']['text'];
  227. }
  228. else if (isset($_SESSION['theme']['logo']['text']) && $_SESSION['theme']['logo']['text'] != '') {
  229. $login_logo_source = $_SESSION['theme']['logo']['text'];
  230. }
  231. else {
  232. $login_logo_source = PROJECT_PATH.'/themes/default/images/logo_login.png';
  233. }
  234. //determine logo dimensions
  235. if (isset($_SESSION['theme']['login_logo_width']['text']) && $_SESSION['theme']['login_logo_width']['text'] != '') {
  236. $login_logo_width = $_SESSION['theme']['login_logo_width']['text'];
  237. }
  238. else {
  239. $login_logo_width = 'auto; max-width: 300px';
  240. }
  241. if (isset($_SESSION['theme']['login_logo_height']['text']) && $_SESSION['theme']['login_logo_height']['text'] != '') {
  242. $login_logo_height = $_SESSION['theme']['login_logo_height']['text'];
  243. }
  244. else {
  245. $login_logo_height = 'auto; max-height: 300px';
  246. }
  247. $view->assign('login_logo_source', $login_logo_source);
  248. $view->assign('login_logo_width', $login_logo_width);
  249. $view->assign('login_logo_height', $login_logo_height);
  250. //login page
  251. //$view->assign('login_page', $login_page);
  252. //messages
  253. $view->assign('messages', message::html(true, ' '));
  254. //session timer
  255. if (
  256. $authenticated &&
  257. file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH.'/app/session_timer/session_timer.php') &&
  258. $_SESSION['security']['session_timer_enabled']['boolean'] == 'true'
  259. ) {
  260. include_once PROJECT_PATH.'app/session_timer/session_timer.php';
  261. $view->assign('session_timer', $session_timer);
  262. }
  263. //render the view
  264. $output = $view->render('template.php');
  265. //unset background image
  266. unset($_SESSION['background_image']);
  267. //send the output to the browser
  268. echo $output;
  269. unset($output);
  270. //$statsauth = "a3az349x2bf3fdfa8dbt7x34fas5X";
  271. //require_once "stats/stat_sadd.php";
  272. ?>