footer.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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-2024
  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 = 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. $settings_array['theme']['menu_side_item_main_sub_icon_contract'] = !empty($settings_array['theme']['menu_side_item_main_sub_icon_contract']) ? explode(' ', $settings_array['theme']['menu_side_item_main_sub_icon_contract'])[1] : null;
  139. $settings_array['theme']['menu_side_item_main_sub_icon_expand'] = !empty($settings_array['theme']['menu_side_item_main_sub_icon_expand']) ? explode(' ', $settings_array['theme']['menu_side_item_main_sub_icon_expand'])[1] : null;
  140. //assign the setings
  141. $view->assign('settings', $settings_array);
  142. }
  143. //background video
  144. if (!empty($_SESSION['theme']['background_video']) && is_array($_SESSION['theme']['background_video'])) {
  145. $view->assign('background_video', $_SESSION['theme']['background_video'][0]);
  146. }
  147. //document title
  148. if (isset($_SESSION['theme']['title']['text']) && $_SESSION['theme']['title']['text'] != '') {
  149. $document_title = $_SESSION['theme']['title']['text'];
  150. }
  151. $document_title = (!empty($document['title']) ? $document['title'].' - ' : null).($document_title ?? '');
  152. $view->assign('document_title', $document_title);
  153. //domain selector control
  154. $domain_selector_enabled = permission_exists('domain_select') && count($_SESSION['domains']) > 1 ? true : false;
  155. $view->assign('domain_selector_enabled', $domain_selector_enabled);
  156. //browser name
  157. $user_agent = http_user_agent();
  158. $browser_version = $user_agent['version'];
  159. $view->assign('browser_name', $user_agent['name']);
  160. $view->assign('browser_name_short', $user_agent['name_short']);
  161. //login state
  162. $authenticated = isset($_SESSION['username']) && !empty($_SESSION['username']) ? true : false;
  163. $view->assign('authenticated', $authenticated);
  164. //domains application path
  165. $view->assign('domains_app_path', PROJECT_PATH.(file_exists($_SERVER['DOCUMENT_ROOT'].'/app/domains/domains.php') ? '/app/domains/domains.php' : '/core/domains/domains.php'));
  166. //domain count
  167. $view->assign('domain_count', is_array($_SESSION['domains']) ? sizeof($_SESSION['domains']) : 0);
  168. //domain selector row background colors
  169. $view->assign('domain_selector_background_color_1', !empty($_SESSION['theme']['domain_inactive_background_color'][0]) != '' ? $_SESSION['theme']['domain_inactive_background_color'][0] : '#eaedf2');
  170. $view->assign('domain_selector_background_color_2', !empty($_SESSION['theme']['domain_inactive_background_color'][1]) != '' ? $_SESSION['theme']['domain_inactive_background_color'][1] : '#ffffff');
  171. $view->assign('domain_active_background_color', !empty($_SESSION['theme']['domain_active_background_color']['text']) ? $_SESSION['theme']['domain_active_background_color']['text'] : '#eeffee');
  172. //domain list
  173. $view->assign('domains', $_SESSION['domains']);
  174. //domain uuid
  175. $view->assign('domain_uuid', $_SESSION['domain_uuid']);
  176. //menu container
  177. //load menu array into the session
  178. if (!isset($_SESSION['menu']['array'])) {
  179. $menu = new menu;
  180. $menu->menu_uuid = $_SESSION['domain']['menu']['uuid'];
  181. $_SESSION['menu']['array'] = $menu->menu_array();
  182. unset($menu);
  183. }
  184. //build menu by style
  185. switch ($_SESSION['theme']['menu_style']['text']) {
  186. case 'side':
  187. $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'));
  188. if ($_SESSION['theme']['menu_side_state']['text'] != 'hidden') {
  189. $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;
  190. }
  191. $container_open = "<div id='menu_side_container' style='width: ".(in_array($_SESSION['theme']['menu_side_state']['text'], ['expanded','hidden']) ? ($_SESSION['theme']['menu_side_width_expanded']['text'] ?? 225) : ($_SESSION['theme']['menu_side_width_contracted']['text'] ?? 60))."px; ".($_SESSION['theme']['menu_side_state']['text'] == 'hidden' ? "display: none;'" : "' class='hide-xs'").$menu_side_toggle." >\n";
  192. $menu = new menu;
  193. $menu->text = $text;
  194. $menu_html = $menu->menu_vertical($_SESSION['menu']['array']);
  195. unset($menu);
  196. break;
  197. case 'inline':
  198. $container_open = "<div class='container-fluid' style='padding: 0;' align='".($_SESSION['theme']['logo_align']['text'] != '' ? $_SESSION['theme']['logo_align']['text'] : 'left')."'>\n";
  199. if ($_SERVER['PHP_SELF'] != PROJECT_PATH.'/core/install/install.php') {
  200. $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>";
  201. }
  202. $menu = new menu;
  203. $menu->text = $text;
  204. $menu_html = $menu->menu_horizontal($_SESSION['menu']['array']);
  205. unset($menu);
  206. break;
  207. case 'static':
  208. $container_open = "<div class='container-fluid' style='padding: 0;' align='center'>\n";
  209. $menu = new menu;
  210. $menu->text = $text;
  211. $menu_html = $menu->menu_horizontal($_SESSION['menu']['array']);
  212. unset($menu);
  213. break;
  214. case 'fixed':
  215. default:
  216. $menu = new menu;
  217. $menu->text = $text;
  218. $menu_html = $menu->menu_horizontal($_SESSION['menu']['array']);
  219. unset($menu);
  220. $container_open = "<div class='container-fluid' style='padding: 0;' align='center'>\n";
  221. break;
  222. }
  223. $view->assign('logo', $logo);
  224. $view->assign('menu', $menu_html);
  225. $view->assign('container_open', $container_open);
  226. $view->assign('container_close', '</div>');
  227. $view->assign('document_body', $body);
  228. $view->assign('current_year', date('Y'));
  229. //login logo
  230. //determine logo source
  231. if (isset($_SESSION['theme']['logo_login']['text']) && $_SESSION['theme']['logo_login']['text'] != '') {
  232. $login_logo_source = $_SESSION['theme']['logo_login']['text'];
  233. }
  234. else if (isset($_SESSION['theme']['logo']['text']) && $_SESSION['theme']['logo']['text'] != '') {
  235. $login_logo_source = $_SESSION['theme']['logo']['text'];
  236. }
  237. else {
  238. $login_logo_source = PROJECT_PATH.'/themes/default/images/logo_login.png';
  239. }
  240. //determine logo dimensions
  241. if (isset($_SESSION['theme']['login_logo_width']['text']) && $_SESSION['theme']['login_logo_width']['text'] != '') {
  242. $login_logo_width = $_SESSION['theme']['login_logo_width']['text'];
  243. }
  244. else {
  245. $login_logo_width = 'auto; max-width: 300px';
  246. }
  247. if (isset($_SESSION['theme']['login_logo_height']['text']) && $_SESSION['theme']['login_logo_height']['text'] != '') {
  248. $login_logo_height = $_SESSION['theme']['login_logo_height']['text'];
  249. }
  250. else {
  251. $login_logo_height = 'auto; max-height: 300px';
  252. }
  253. $view->assign('login_logo_source', $login_logo_source);
  254. $view->assign('login_logo_width', $login_logo_width);
  255. $view->assign('login_logo_height', $login_logo_height);
  256. //login page
  257. //$view->assign('login_page', $login_page);
  258. //messages
  259. $view->assign('messages', message::html(true, ' '));
  260. //session timer
  261. if (
  262. $authenticated &&
  263. file_exists($_SERVER['DOCUMENT_ROOT'].PROJECT_PATH.'/app/session_timer/session_timer.php') &&
  264. $_SESSION['security']['session_timer_enabled']['boolean'] == 'true'
  265. ) {
  266. include_once PROJECT_PATH.'app/session_timer/session_timer.php';
  267. $view->assign('session_timer', $session_timer);
  268. }
  269. //render the view
  270. $output = $view->render('template.php');
  271. //unset background image
  272. unset($_SESSION['background_image']);
  273. //send the output to the browser
  274. echo $output;
  275. unset($output);
  276. //$statsauth = "a3az349x2bf3fdfa8dbt7x34fas5X";
  277. //require_once "stats/stat_sadd.php";
  278. ?>