Subversion Repositories oidplus

Rev

Rev 775 | 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. $add_css_args = array();
  66. if (class_exists('OIDplusPageAdminColors')) {
  67.         // Usually, such things would be done using "features" (implementsFeature),
  68.         // but there are following reasons why we DON'T do it:
  69.         // 1. Just having a "CSS URL parameter feature" would change the URL parameter,
  70.         //    but it would not affect the custom code in oidplus.min.css.php
  71.         // 2. The JS function OIDplusPageAdminColors.test_color_theme() has an hardcoded set of parameters
  72.         //    and does not follow the arguments that might be set by other plugins.
  73.         $add_css_args[] = 'theme='.urlencode(OIDplus::config()->getValue('design'));
  74.         $add_css_args[] = 'invert='.urlencode(OIDplus::config()->getValue('color_invert'));
  75.         $add_css_args[] = 'h_shift='.urlencode(number_format(OIDplus::config()->getValue('color_hue_shift')/360,5,'.',''));
  76.         $add_css_args[] = 's_shift='.urlencode(number_format(OIDplus::config()->getValue('color_sat_shift')/100,5,'.',''));
  77.         $add_css_args[] = 'v_shift='.urlencode(number_format(OIDplus::config()->getValue('color_val_shift')/100,5,'.',''));
  78. }
  79. $add_css_args = count($add_css_args) > 0 ? '?'.implode('&',$add_css_args) : '';
  80.  
  81. // Get theme color (color of title bar)
  82. $theme_color = '';
  83. $plugins = OIDplus::getDesignPlugins();
  84. foreach ($plugins as $plugin) {
  85.         if ((basename($plugin->getPluginDirectory())) == OIDplus::config()->getValue('design','default')) {
  86.                 $theme_color = $plugin->getThemeColor();
  87.                 if (($theme_color != '') && class_exists('OIDplusPageAdminColors')) {
  88.                         $hs = OIDplus::config()->getValue('color_hue_shift',0)/360;
  89.                         $ss = OIDplus::config()->getValue('color_sat_shift',0)/100;
  90.                         $vs = OIDplus::config()->getValue('color_val_shift',0)/100;
  91.                         $theme_color = changeHueOfCSS($theme_color, $hs, $ss, $vs); // "changeHueOfCSS" can also change a single color value if it has the form #xxyyzz or #xyz
  92.                 }
  93.         }
  94. }
  95.  
  96. ?><!DOCTYPE html>
  97. <html lang="<?php echo substr(OIDplus::getCurrentLang(),0,2); ?>">
  98.  
  99. <head>
  100.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  101.         <meta name="OIDplus-SystemTitle" content="<?php echo htmlentities(OIDplus::config()->getValue('system_title')); /* Do not remove. This meta tag is acessed by oidplus_base.js */ ?>">
  102.         <?php
  103.         if ($theme_color != '') echo '<meta name="theme-color" content="'.$theme_color.'">';
  104.         ?>
  105.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  106.  
  107.         <title><?php echo htmlentities(combine_systemtitle_and_pagetitle(OIDplus::config()->getValue('system_title'), $static_title)); ?></title>
  108.  
  109.         <script src="polyfill.min.js.php"></script>
  110.         <?php
  111.         echo OIDplus::getActiveCaptchaPlugin()->captchaDomHead();
  112.         ?>
  113.         <script src="oidplus.min.js.php"></script>
  114.  
  115.         <link rel="stylesheet" href="oidplus.min.css.php<?php echo htmlentities($add_css_args); ?>">
  116.         <link rel="shortcut icon" type="image/x-icon" href="favicon.ico.php">
  117.         <link rel="canonical" href="<?php echo OIDplus::canonicalURL(); ?>">
  118. </head>
  119.  
  120. <body>
  121.  
  122. <div id="loading" style="display:none">Loading&#8230;</div>
  123.  
  124. <div id="frames">
  125.         <div id="content_window" class="borderbox">
  126.                 <?php
  127.                 $static_content = preg_replace_callback(
  128.                         '|<a\s([^>]*)href="mailto:([^"]+)"([^>]*)>([^<]*)</a>|ismU',
  129.                         function ($treffer) {
  130.                                 $email = $treffer[2];
  131.                                 $text = $treffer[4];
  132.                                 return OIDplus::mailUtils()->secureEmailAddress($email, $text, 1); // AntiSpam
  133.                         }, $static_content);
  134.  
  135.                 echo '<h1 id="real_title">';
  136.                 if ($static_icon != '') echo '<img src="'.htmlentities($static_icon).'" width="48" height="48" alt=""> ';
  137.                 echo htmlentities($static_title).'</h1>';
  138.                 echo '<div id="real_content">'.$static_content.'</div>';
  139.                 if ((!isset($_SERVER['REQUEST_METHOD'])) || ($_SERVER['REQUEST_METHOD'] == 'GET')) {
  140.                         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>';
  141.                         echo '</p>';
  142.                 }
  143.                 echo '<br>';
  144.                 ?>
  145.         </div>
  146.  
  147.         <div id="system_title_bar">
  148.                 <?php
  149.                 echo '<div id="system_title_menu" onclick="mobileNavButtonClick(this)" onmouseenter="mobileNavButtonHover(this)" onmouseleave="mobileNavButtonHover(this)">';
  150.                 echo '  <div id="bar1"></div>';
  151.                 echo '  <div id="bar2"></div>';
  152.                 echo '  <div id="bar3"></div>';
  153.                 echo '</div>';
  154.                 echo '';
  155.                 echo '<div id="system_title_text">';
  156.                 echo '  <a '.OIDplus::gui()->link('oidplus:system').' id="system_title_a">';
  157.                 echo '          <span id="system_title_logo"></span>';
  158.                 echo '          <span id="system_title_1">'._L('ViaThinkSoft OIDplus 2.0').'</span><br>';
  159.                 echo '          <span id="system_title_2">'.htmlentities(OIDplus::config()->getValue('system_title')).'</span>';
  160.                 echo '  </a>';
  161.                 echo '</div>';
  162.                 ?>
  163.         </div>
  164.  
  165.         <?php
  166.         echo OIDplus::gui()->getLanguageBox($static_node_id, true);
  167.         ?>
  168.  
  169.         <div id="gotobox">
  170.                 <?php
  171.                 echo '<input type="text" name="goto" id="gotoedit" value="'.htmlentities($static_node_id).'">';
  172.                 echo '<input type="button" value="'._L('Go').'" onclick="gotoButtonClicked()" id="gotobutton">';
  173.                 ?>
  174.         </div>
  175.  
  176.         <div id="oidtree" class="borderbox">
  177.                 <?php
  178.                 //echo '<noscript>';
  179.                 //echo '<p><b>'._L('Please enable JavaScript to use all features').'</b></p>';
  180.                 //echo '</noscript>';
  181.                 OIDplus::menuUtils()->nonjs_menu();
  182.                 ?>
  183.         </div>
  184. </div>
  185.  
  186. </body>
  187. </html>
  188. <?php
  189.  
  190. $cont = ob_get_contents();
  191. ob_end_clean();
  192.  
  193. OIDplus::invoke_shutdown();
  194.  
  195. echo $cont;
  196.