Subversion Repositories oidplus

Rev

Rev 778 | Rev 820 | 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. $static_node_id = OIDplus::prefilterQuery($static_node_id, false);
  33.  
  34. $static = OIDplus::gui()->generateContentPage($static_node_id);
  35. $static_title = $static['title'];
  36. $static_icon = $static['icon'];
  37. $static_content = $static['text'];
  38.  
  39. if (!isset($_COOKIE['csrf_token'])) {
  40.         // This is the main CSRF token used for AJAX.
  41.         $token = OIDplus::authUtils()->genCSRFToken();
  42.         OIDplus::cookieUtils()->setcookie('csrf_token', $token, 0, false);
  43.         unset($token);
  44. }
  45.  
  46. if (!isset($_COOKIE['csrf_token_weak'])) {
  47.         // This CSRF token is created with SameSite=Lax and must be used
  48.         // for OAuth 2.0 redirects or similar purposes.
  49.         $token = OIDplus::authUtils()->genCSRFToken();
  50.         OIDplus::cookieUtils()->setcookie('csrf_token_weak', $token, 0, false, 'Lax');
  51.         unset($token);
  52. }
  53.  
  54. OIDplus::handleLangArgument();
  55.  
  56. function combine_systemtitle_and_pagetitle($systemtitle, $pagetitle) {
  57.         // Please also change the function in oidplus_base.js
  58.         if ($systemtitle == $pagetitle) {
  59.                 return $systemtitle;
  60.         } else {
  61.                 return $pagetitle . ' - ' . $systemtitle;
  62.         }
  63. }
  64.  
  65. // Get theme color (color of title bar)
  66. $design_plugin = OIDplus::getActiveDesignPlugin();
  67. $theme_color = is_null($design_plugin) ? '' : $design_plugin->getThemeColor();
  68.  
  69. $head_elems = array();
  70. $head_elems[] = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
  71. $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
  72. if ($theme_color != '') $head_elems[] = '<meta name="theme-color" content="'.$theme_color.'">';
  73. $head_elems[] = '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
  74. $head_elems[] = '<title>'.htmlentities(combine_systemtitle_and_pagetitle(OIDplus::config()->getValue('system_title'), $static_title)).'</title>';
  75. $head_elems[] = '<script src="polyfill.min.js.php"></script>';
  76. $head_elems[] = OIDplus::getActiveCaptchaPlugin()->captchaDomHead();
  77. $head_elems[] = '<script src="oidplus.min.js.php"></script>';
  78. $head_elems[] = '<link rel="stylesheet" href="oidplus.min.css.php">';
  79. $head_elems[] = '<link rel="shortcut icon" type="image/x-icon" href="favicon.ico.php">';
  80. $head_elems[] = '<link rel="canonical" href="'.OIDplus::canonicalURL().'">';
  81.  
  82. $plugins = OIDplus::getPagePlugins();
  83. foreach ($plugins as $plugin) {
  84.         $plugin->htmlHeaderUpdate($head_elems);
  85. }
  86.  
  87. // ---
  88.  
  89. echo '<!DOCTYPE html>'."\n";
  90. echo '<html lang="'.substr(OIDplus::getCurrentLang(),0,2).'">';
  91. echo '<head>';
  92. echo implode("\n",$head_elems);
  93. echo '</head>';
  94.  
  95. echo '<body>';
  96.  
  97. echo '<div id="loading" style="display:none">Loading&#8230;</div>';
  98.  
  99. echo '<div id="frames">';
  100. echo '<div id="content_window" class="borderbox">';
  101.  
  102. $static_content = preg_replace_callback(
  103.         '|<a\s([^>]*)href="mailto:([^"]+)"([^>]*)>([^<]*)</a>|ismU',
  104.         function ($treffer) {
  105.                 $email = $treffer[2];
  106.                 $text = $treffer[4];
  107.                 return OIDplus::mailUtils()->secureEmailAddress($email, $text, 1); // AntiSpam
  108.         }, $static_content);
  109.  
  110. echo '<h1 id="real_title">';
  111. if ($static_icon != '') echo '<img src="'.htmlentities($static_icon).'" width="48" height="48" alt=""> ';
  112. echo htmlentities($static_title).'</h1>';
  113. echo '<div id="real_content">'.$static_content.'</div>';
  114. if ((!isset($_SERVER['REQUEST_METHOD'])) || ($_SERVER['REQUEST_METHOD'] == 'GET')) {
  115.         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>';
  116.         echo '</p>';
  117. }
  118. echo '<br>';
  119.  
  120. echo '</div>';
  121.  
  122. echo '<div id="system_title_bar">';
  123.  
  124. echo '<div id="system_title_menu" onclick="mobileNavButtonClick(this)" onmouseenter="mobileNavButtonHover(this)" onmouseleave="mobileNavButtonHover(this)">';
  125. echo '  <div id="bar1"></div>';
  126. echo '  <div id="bar2"></div>';
  127. echo '  <div id="bar3"></div>';
  128. echo '</div>';
  129.  
  130. echo '<div id="system_title_text">';
  131. echo '  <a '.OIDplus::gui()->link('oidplus:system').' id="system_title_a">';
  132. echo '          <span id="system_title_logo"></span>';
  133. echo '          <span id="system_title_1">'._L('ViaThinkSoft OIDplus 2.0').'</span><br>';
  134. echo '          <span id="system_title_2">'.htmlentities(OIDplus::config()->getValue('system_title')).'</span>';
  135. echo '  </a>';
  136. echo '</div>';
  137.  
  138. echo '</div>';
  139.  
  140. echo OIDplus::gui()->getLanguageBox($static_node_id, true);
  141.  
  142. echo '<div id="gotobox">';
  143. echo '<input type="text" name="goto" id="gotoedit" value="'.htmlentities($static_node_id).'">';
  144. echo '<input type="button" value="'._L('Go').'" onclick="gotoButtonClicked()" id="gotobutton">';
  145. echo '</div>';
  146.  
  147. echo '<div id="oidtree" class="borderbox">';
  148. //echo '<noscript>';
  149. //echo '<p><b>'._L('Please enable JavaScript to use all features').'</b></p>';
  150. //echo '</noscript>';
  151. OIDplus::menuUtils()->nonjs_menu();
  152. echo '</div>';
  153.  
  154. echo '</div>';
  155.  
  156. echo '</body>';
  157. echo '</html>';
  158.  
  159. $cont = ob_get_contents();
  160. ob_end_clean();
  161.  
  162. OIDplus::invoke_shutdown();
  163.  
  164. echo $cont;
  165.