Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

136 lines
3.2 KiB

  1. <?php
  2. require_once("boot.php");
  3. $a = new App;
  4. $debug_text = ''; // Debugging functions should never be used on production systems.
  5. // Setup the language and database.
  6. $install = ((file_exists('.htconfig.php')) ? false : true);
  7. @include(".htconfig.php");
  8. if(isset($lang) && strlen($lang))
  9. load_translation_table($lang);
  10. require_once("dba.php");
  11. $db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
  12. unset($db_host, $db_user, $db_pass, $db_data);
  13. if(! $install)
  14. require_once("session.php");
  15. require_once("datetime.php");
  16. date_default_timezone_set(($default_timezone) ? $default_timezone : 'UTC');
  17. $a->init_pagehead();
  18. session_start();
  19. if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
  20. require("auth.php");
  21. if(! x($_SESSION,'authenticated'))
  22. header('X-Account-Management-Status: none');
  23. if(! x($_SESSION,'sysmsg'))
  24. $_SESSION['sysmsg'] = '';
  25. if($install)
  26. $a->module = 'install';
  27. else
  28. check_config($a);
  29. if(strlen($a->module)) {
  30. if(file_exists("mod/{$a->module}.php")) {
  31. include("mod/{$a->module}.php");
  32. $a->module_loaded = true;
  33. }
  34. else {
  35. header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
  36. notice( t('Page not found.' ) . EOL);
  37. }
  38. }
  39. if($a->module_loaded) {
  40. $a->page['page_title'] = $a->module;
  41. if(function_exists($a->module . '_init')) {
  42. $func = $a->module . '_init';
  43. $func($a);
  44. }
  45. if(($_SERVER['REQUEST_METHOD'] === 'POST') && (! $a->error)
  46. && (function_exists($a->module . '_post'))
  47. && (! x($_POST,'auth-params'))) {
  48. $func = $a->module . '_post';
  49. $func($a);
  50. }
  51. if((! $a->error) && (function_exists($a->module . '_afterpost'))) {
  52. $func = $a->module . '_afterpost';
  53. $func($a);
  54. }
  55. if((! $a->error) && (function_exists($a->module . '_content'))) {
  56. $func = $a->module . '_content';
  57. if(! x($a->page,'content'))
  58. $a->page['content'] = '';
  59. $a->page['content'] .= $func($a);
  60. }
  61. }
  62. if(stristr($_SESSION['sysmsg'], t('Permission denied'))) {
  63. header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.'));
  64. }
  65. // report anything important happening
  66. if(x($_SESSION,'sysmsg')) {
  67. $a->page['content'] = "<div id=\"sysmsg\" class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
  68. . ((x($a->page,'content')) ? $a->page['content'] : '');
  69. unset($_SESSION['sysmsg']);
  70. }
  71. // Feel free to comment out this line on production sites.
  72. $a->page['content'] .= $debug_text;
  73. $a->page['content'] .= '<div id="pause"></div>';
  74. // build page
  75. // Navigation (menu) template
  76. if($a->module != 'install')
  77. require_once("nav.php");
  78. // make sure the desired theme exists, though if the default theme doesn't exist we're stuffed.
  79. if((x($_SESSION,'theme')) && (! file_exists('/view/theme/' . $_SESSION['theme'] . '/style.css')))
  80. unset($_SESSION['theme']);
  81. $a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array(
  82. '$stylesheet' => $a->get_baseurl() . '/view/theme/'
  83. . ((x($_SESSION,'theme')) ? $_SESSION['theme'] : 'default')
  84. . '/style.css'
  85. ));
  86. $page = $a->page;
  87. $profile = $a->profile;
  88. $lang = get_config('system','language');
  89. header("Content-type: text/html; charset=utf-8");
  90. $template = "view/" . (($lang) ? $lang . "/" : "")
  91. . ((x($a->page,'template')) ? $a->page['template'] : 'default' )
  92. . ".php";
  93. require_once($template);
  94. session_write_close();
  95. exit;