Subversion Repositories oidplus

Rev

Rev 257 | Rev 294 | 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 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('html_exception_handler');
  25. function html_exception_handler($exception) {
  26.         if ($exception instanceof OIDplusConfigInitializationException) {
  27.                 echo "<h1>OIDplus initialization error</h1>";
  28.                 echo '<p>'.htmlentities($exception->getMessage()).'</p>';
  29.                 echo '<p>Please check <b>includes/config.inc.php</b>';
  30.                 if (is_dir(__DIR__ . '/setup')) {
  31.                         echo ' or run <a href="'.OIDplus::getSystemUrl().'setup/">setup</a> again';
  32.                 }
  33.                 echo '</p>';
  34.         } else {
  35.                 echo "<h1>OIDplus error</h1>";
  36.                 // ENT_SUBSTITUTE because ODBC drivers might return ANSI instead of UTF-8 stuff
  37.                 echo '<p>'.htmlentities($exception->getMessage(), ENT_SUBSTITUTE).'</p>';
  38.                 echo '<p><b>Technical information about the problem:</b></p>';
  39.                 echo '<pre>';
  40.                 echo get_class($exception)."\n";
  41.                 echo 'at '.$exception->getFile().'('.$exception->getLine().")\n";
  42.                 echo "Stacktrace:\n";
  43.                 echo $exception->getTraceAsString();
  44.                 echo '</pre>';
  45.         }
  46. }
  47.  
  48. ob_start(); // allow cookie headers to be sent
  49.  
  50. OIDplus::init(true);
  51.  
  52. $static_node_id = isset($_REQUEST['goto']) ? $_REQUEST['goto'] : 'oidplus:system';
  53. $static = OIDplus::gui()::generateContentPage($static_node_id);
  54. $static_title = $static['title'];
  55. $static_icon = $static['icon'];
  56. $static_content = $static['text'];
  57.  
  58. function combine_systemtitle_and_pagetitle($systemtitle, $pagetitle) {
  59.         if ($systemtitle == $pagetitle) {
  60.                 return $systemtitle;
  61.         } else {
  62.                 return $systemtitle . ' - ' . $pagetitle;
  63.         }
  64. }
  65.  
  66. $sysid_oid = OIDplus::getSystemId(true);
  67. if (!$sysid_oid) $sysid_oid = 'unknown';
  68. header('X-OIDplus-SystemID:'.$sysid_oid);
  69.  
  70. $sys_url = OIDplus::getSystemUrl();
  71. header('X-OIDplus-SystemURL:'.$sys_url);
  72.  
  73. $sys_ver = OIDplus::getVersion();
  74. if (!$sys_ver) $sys_ver = 'unknown';
  75. header('X-OIDplus-SystemVersion:'.$sys_ver);
  76.  
  77. $sys_install_type = OIDplus::getInstallType();
  78. header('X-OIDplus-SystemInstallType:'.$sys_install_type);
  79.  
  80. $sys_title = OIDplus::config()->getValue('system_title');
  81. header('X-OIDplus-SystemTitle:'.$sys_title);
  82.  
  83. if (class_exists('OIDplusPageAdminColors')) {
  84.         $css = 'oidplus.min.css.php?invert='.(OIDplus::config()->getValue('color_invert')).'&h_shift='.(OIDplus::config()->getValue('color_hue_shift')/360).'&s_shift='.(OIDplus::config()->getValue('color_sat_shift')/100).'&v_shift='.(OIDplus::config()->getValue('color_val_shift')/100);
  85. } else {
  86.         $css = 'oidplus.min.css.php';
  87. }
  88.  
  89. $js = 'oidplus.min.js.php';
  90.  
  91. ?><!DOCTYPE html>
  92. <html lang="en">
  93.  
  94. <head>
  95.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  96.         <meta name="OIDplus-SystemID" content="<?php echo htmlentities($sysid_oid); ?>">
  97.         <meta name="OIDplus-SystemURL" content="<?php echo htmlentities($sys_url); ?>">
  98.         <meta name="OIDplus-SystemVersion" content="<?php echo htmlentities($sys_ver); ?>">
  99.         <meta name="OIDplus-SystemInstallType" content="<?php echo htmlentities($sys_install_type); ?>">
  100.         <meta name="OIDplus-SystemTitle" content="<?php echo htmlentities($sys_title); /* Do not remove. This meta tag is acessed by oidplus_base.js */ ?>">
  101.         <meta name="theme-color" content="#A9DCF0">
  102.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  103.  
  104.         <title><?php echo combine_systemtitle_and_pagetitle(OIDplus::config()->getValue('system_title'), $static_title); ?></title>
  105.  
  106.         <script src="<?php echo htmlentities($js); ?>"></script>
  107.  
  108.         <link rel="stylesheet" href="<?php echo htmlentities($css); ?>">
  109.         <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
  110. </head>
  111.  
  112. <body>
  113.  
  114. <div id="frames">
  115.         <div id="content_window" class="borderbox">
  116.                 <?php
  117.                 $static_content = preg_replace_callback(
  118.                         '|<a\s([^>]*)href="mailto:([^"]+)"([^>]*)>([^<]*)</a>|ismU',
  119.                         function ($treffer) {
  120.                                 $email = $treffer[2];
  121.                                 $text = $treffer[4];
  122.                                 return OIDplus::mailUtils()->secureEmailAddress($email, $text, 1); // AntiSpam
  123.                         }, $static_content);
  124.  
  125.                 echo '<h1 id="real_title">';
  126.                 if ($static_icon != '') echo '<img src="'.htmlentities($static_icon).'" width="48" height="48" alt=""> ';
  127.                 echo htmlentities($static_title).'</h1>';
  128.                 echo '<div id="real_content">'.$static_content.'</div>';
  129.                 if ($_SERVER['REQUEST_METHOD'] == 'GET') {
  130.                         echo '<br><p><img src="img/share.png" width="15" height="15" alt="Share"> <a href="?goto='.htmlentities($static_node_id).'" id="static_link" class="gray_footer_font">Static link to this page</a>';
  131.                         echo '</p>';
  132.                 }
  133.                 echo '<br>';
  134.                 ?>
  135.         </div>
  136.  
  137.         <div id="system_title_bar">
  138.                 <div id="system_title_menu" onclick="mobileNavButtonClick(this)" onmouseenter="mobileNavButtonHover(this)" onmouseleave="mobileNavButtonHover(this)">
  139.                         <div id="bar1"></div>
  140.                         <div id="bar2"></div>
  141.                         <div id="bar3"></div>
  142.                 </div>
  143.  
  144.                 <div id="system_title_text">
  145.                         <a <?php echo OIDplus::gui()->link('oidplus:system'); ?>>
  146.                                 <span id="system_title_1">ViaThinkSoft OIDplus 2.0</span><br>
  147.                                 <span id="system_title_2"><?php echo htmlentities(OIDplus::config()->getValue('system_title')); ?></span>
  148.                         </a>
  149.                 </div>
  150.         </div>
  151.  
  152.         <div id="gotobox">
  153.                 <input type="text" name="goto" id="gotoedit" value="<?php echo htmlentities($static_node_id); ?>">
  154.                 <input type="button" value="Go" onclick="gotoButtonClicked()" id="gotobutton">
  155.         </div>
  156.  
  157.         <div id="oidtree" class="borderbox">
  158.                 <!-- <noscript>
  159.                         <p><b>Please enable JavaScript to use all features</b></p>
  160.                 </noscript> -->
  161.                 <?php OIDplus::menuUtils()->nonjs_menu(); ?>
  162.         </div>
  163. </div>
  164.  
  165. </body>
  166. </html>
  167. <?php
  168.  
  169. $cont = ob_get_contents();
  170. ob_end_clean();
  171.  
  172. echo $cont;
  173.