footer.php 14 KB

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