Subversion Repositories oidplus

Rev

Rev 974 | Rev 1018 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
  6.  *
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  *
  11.  *     http://www.apache.org/licenses/LICENSE-2.0
  12.  *
  13.  * Unless required by applicable law or agreed to in writing, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  */
  19.  
  20. header('Content-Type:text/html; charset=UTF-8');
  21.  
  22. require_once __DIR__ . '/includes/oidplus.inc.php';
  23.  
  24. set_exception_handler(array('OIDplusGui', 'html_exception_handler'));
  25.  
  26. ob_start(); // allow cookie headers to be sent
  27.  
  28. OIDplus::init(true);
  29.  
  30. $static_node_id = isset($_REQUEST['goto']) ? $_REQUEST['goto'] : 'oidplus:system';
  31.  
  32. if (isset($_REQUEST['h404'])) {
  33.         $handled = false;
  34.         $plugins = OIDplus::getPagePlugins();
  35.         foreach ($plugins as $plugin) {
  36.                 if ($plugin->handle404($_REQUEST['h404'])) $handled = true;
  37.         }
  38.         if (!$handled) {
  39.                 header('Location:'.OIDplus::webpath().'?goto='.urlencode('oidplus:err:'.$_REQUEST['h404']));
  40.                 die();
  41.         }
  42. }
  43.  
  44. $static_node_id = OIDplus::prefilterQuery($static_node_id, false);
  45.  
  46. $static = OIDplus::gui()->generateContentPage($static_node_id);
  47. $static_title = $static['title'];
  48. $static_icon = $static['icon'];
  49. $static_content = $static['text'];
  50.  
  51. if (!isset($_COOKIE['csrf_token'])) {
  52.         // This is the main CSRF token used for AJAX.
  53.         $token = OIDplus::authUtils()->genCSRFToken();
  54.         OIDplus::cookieUtils()->setcookie('csrf_token', $token, 0, false);
  55.         unset($token);
  56. }
  57.  
  58. if (!isset($_COOKIE['csrf_token_weak'])) {
  59.         // This CSRF token is created with SameSite=Lax and must be used
  60.         // for OAuth 2.0 redirects or similar purposes.
  61.         $token = OIDplus::authUtils()->genCSRFToken();
  62.         OIDplus::cookieUtils()->setcookie('csrf_token_weak', $token, 0, false, 'Lax');
  63.         unset($token);
  64. }
  65.  
  66. OIDplus::handleLangArgument();
  67.  
  68. function combine_systemtitle_and_pagetitle($systemtitle, $pagetitle) {
  69.         // Please also change the function in oidplus_base.js
  70.         if ($systemtitle == $pagetitle) {
  71.                 return $systemtitle;
  72.         } else {
  73.                 return $pagetitle . ' - ' . $systemtitle;
  74.         }
  75. }
  76.  
  77. // Get theme color (color of title bar)
  78. $design_plugin = OIDplus::getActiveDesignPlugin();
  79. $theme_color = is_null($design_plugin) ? '' : $design_plugin->getThemeColor();
  80.  
  81. $head_elems = array();
  82. $head_elems[] = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
  83. $head_elems[] = '<meta name="OIDplus-SystemTitle" content="'.htmlentities(OIDplus::config()->getValue('system_title')).'">'; // Do not remove. This meta tag is acessed by oidplus_base.js
  84. if ($theme_color != '') $head_elems[] = '<meta name="theme-color" content="'.htmlentities($theme_color).'">';
  85. $head_elems[] = '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
  86. $head_elems[] = '<title>'.htmlentities(combine_systemtitle_and_pagetitle(OIDplus::config()->getValue('system_title'), $static_title)).'</title>';
  87. $head_elems[] = '<script src="polyfill.min.js.php"></script>';
  88. $head_elems[] = OIDplus::getActiveCaptchaPlugin()->captchaDomHead();
  89. $head_elems[] = '<script src="oidplus.min.js.php"></script>';
  90. $head_elems[] = '<link rel="stylesheet" href="oidplus.min.css.php">';
  91. $head_elems[] = '<link rel="shortcut icon" type="image/x-icon" href="favicon.ico.php">';
  92. $head_elems[] = '<link rel="canonical" href="'.htmlentities(OIDplus::canonicalURL()).'">';
  93.  
  94. $plugins = OIDplus::getPagePlugins();
  95. foreach ($plugins as $plugin) {
  96.         $plugin->htmlHeaderUpdate($head_elems);
  97. }
  98.  
  99. // ---
  100.  
  101. echo "<!DOCTYPE html>\n";
  102.  
  103. echo "<html lang=\"".substr(OIDplus::getCurrentLang(),0,2)."\">\n";
  104. echo "<head>\n";
  105. echo "\t".implode("\n\t",$head_elems)."\n";
  106. echo "</head>\n";
  107.  
  108. echo "<body>\n";
  109.  
  110. echo '<div id="loading" style="display:none">Loading&#8230;</div>';
  111.  
  112. echo '<div id="frames">';
  113. echo '<div id="content_window" class="borderbox">';
  114.  
  115. echo '<h1 id="real_title">';
  116. if ($static_icon != '') echo '<img src="'.htmlentities($static_icon).'" width="48" height="48" alt=""> ';
  117. echo htmlentities($static_title).'</h1>';
  118. echo '<div id="real_content">'.$static_content.'</div>';
  119. if ((!isset($_SERVER['REQUEST_METHOD'])) || ($_SERVER['REQUEST_METHOD'] == 'GET')) {
  120.         echo '<br><p><img src="img/share.png" width="15" height="15" alt="'._L('Share').'"> <a href="?goto='.htmlentities($static_node_id).'" id="static_link" class="gray_footer_font">'._L('Static link to this page').'</a>';
  121.         echo '</p>';
  122. }
  123. echo '<br>';
  124.  
  125. echo '</div>';
  126.  
  127. echo '<div id="system_title_bar">';
  128.  
  129. echo '<div id="system_title_menu" onclick="mobileNavButtonClick(this)" onmouseenter="mobileNavButtonHover(this)" onmouseleave="mobileNavButtonHover(this)">';
  130. echo '  <div id="bar1"></div>';
  131. echo '  <div id="bar2"></div>';
  132. echo '  <div id="bar3"></div>';
  133. echo '</div>';
  134.  
  135. echo '<div id="system_title_text">';
  136. echo '  <a '.OIDplus::gui()->link('oidplus:system').' id="system_title_a">';
  137. echo '          <span id="system_title_logo"></span>';
  138. echo '          <span id="system_title_1">'.htmlentities(OIDplus::getEditionInfo()['vendor'].' OIDplus 2.0').'</span><br>';
  139. echo '          <span id="system_title_2">'.htmlentities(OIDplus::config()->getValue('system_title')).'</span>';
  140. echo '  </a>';
  141. echo '</div>';
  142.  
  143. echo '</div>';
  144.  
  145. echo OIDplus::gui()->getLanguageBox($static_node_id, true);
  146.  
  147. echo '<div id="gotobox">';
  148. echo '<input type="text" name="goto" id="gotoedit" value="'.htmlentities($static_node_id).'">';
  149. echo '<input type="button" value="'._L('Go').'" onclick="gotoButtonClicked()" id="gotobutton">';
  150. echo '</div>';
  151.  
  152. echo '<div id="oidtree" class="borderbox">';
  153. //echo '<noscript>';
  154. //echo '<p><b>'._L('Please enable JavaScript to use all features').'</b></p>';
  155. //echo '</noscript>';
  156. OIDplus::menuUtils()->nonjs_menu();
  157. echo '</div>';
  158.  
  159. echo '</div>';
  160.  
  161. echo "\n</body>\n";
  162. echo "</html>\n";
  163.  
  164. $cont = ob_get_contents();
  165. ob_end_clean();
  166.  
  167. $plugins = OIDplus::getPagePlugins();
  168. foreach ($plugins as $plugin) {
  169.         $plugin->htmlPostprocess($cont);
  170. }
  171.  
  172. OIDplus::invoke_shutdown();
  173.  
  174. echo $cont;
  175.