Subversion Repositories oidplus

Rev

Rev 349 | Rev 356 | 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(), ENT_SUBSTITUTE).'</p>';
  29.                 echo '<p>Please check <b>userdata/baseconfig/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.         // Please also change the function in oidplus_base.js
  60.         if ($systemtitle == $pagetitle) {
  61.                 return $systemtitle;
  62.         } else {
  63.                 return $pagetitle . ' - ' . $systemtitle;
  64.         }
  65. }
  66.  
  67. $sysid_oid = OIDplus::getSystemId(true);
  68. if (!$sysid_oid) $sysid_oid = 'unknown';
  69. header('X-OIDplus-SystemID:'.$sysid_oid);
  70.  
  71. $sys_url = OIDplus::getSystemUrl();
  72. header('X-OIDplus-SystemURL:'.$sys_url);
  73.  
  74. $sys_ver = OIDplus::getVersion();
  75. if (!$sys_ver) $sys_ver = 'unknown';
  76. header('X-OIDplus-SystemVersion:'.$sys_ver);
  77.  
  78. $sys_install_type = OIDplus::getInstallType();
  79. header('X-OIDplus-SystemInstallType:'.$sys_install_type);
  80.  
  81. $sys_title = OIDplus::config()->getValue('system_title');
  82. header('X-OIDplus-SystemTitle:'.$sys_title);
  83.  
  84. if (class_exists('OIDplusPageAdminColors')) {
  85.         $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);
  86. } else {
  87.         $css = 'oidplus.min.css.php';
  88. }
  89.  
  90. $js = 'oidplus.min.js.php';
  91.  
  92. ?><!DOCTYPE html>
  93. <html lang="en">
  94.  
  95. <head>
  96.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  97.         <meta name="OIDplus-SystemID" content="<?php echo htmlentities($sysid_oid); ?>">
  98.         <meta name="OIDplus-SystemURL" content="<?php echo htmlentities($sys_url); ?>">
  99.         <meta name="OIDplus-SystemVersion" content="<?php echo htmlentities($sys_ver); ?>">
  100.         <meta name="OIDplus-SystemInstallType" content="<?php echo htmlentities($sys_install_type); ?>">
  101.         <meta name="OIDplus-SystemTitle" content="<?php echo htmlentities($sys_title); /* Do not remove. This meta tag is acessed by oidplus_base.js */ ?>">
  102.         <meta name="theme-color" content="#A9DCF0">
  103.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  104.  
  105.         <title><?php echo combine_systemtitle_and_pagetitle(OIDplus::config()->getValue('system_title'), $static_title); ?></title>
  106.  
  107.         <script src="<?php echo htmlentities($js); ?>"></script>
  108.  
  109.         <link rel="stylesheet" href="<?php echo htmlentities($css); ?>">
  110.         <link rel="shortcut icon" type="image/x-icon" href="favicon.ico.php">
  111. </head>
  112.  
  113. <body>
  114.  
  115. <div id="frames">
  116.         <div id="content_window" class="borderbox">
  117.                 <?php
  118.                 $static_content = preg_replace_callback(
  119.                         '|<a\s([^>]*)href="mailto:([^"]+)"([^>]*)>([^<]*)</a>|ismU',
  120.                         function ($treffer) {
  121.                                 $email = $treffer[2];
  122.                                 $text = $treffer[4];
  123.                                 return OIDplus::mailUtils()->secureEmailAddress($email, $text, 1); // AntiSpam
  124.                         }, $static_content);
  125.  
  126.                 echo '<h1 id="real_title">';
  127.                 if ($static_icon != '') echo '<img src="'.htmlentities($static_icon).'" width="48" height="48" alt=""> ';
  128.                 echo htmlentities($static_title).'</h1>';
  129.                 echo '<div id="real_content">'.$static_content.'</div>';
  130.                 if ((!isset($_SERVER['REQUEST_METHOD'])) || ($_SERVER['REQUEST_METHOD'] == 'GET')) {
  131.                         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>';
  132.                         echo '</p>';
  133.                 }
  134.                 echo '<br>';
  135.                 ?>
  136.         </div>
  137.  
  138.         <div id="system_title_bar">
  139.                 <div id="system_title_menu" onclick="mobileNavButtonClick(this)" onmouseenter="mobileNavButtonHover(this)" onmouseleave="mobileNavButtonHover(this)">
  140.                         <div id="bar1"></div>
  141.                         <div id="bar2"></div>
  142.                         <div id="bar3"></div>
  143.                 </div>
  144.  
  145.                 <div id="system_title_text">
  146.                         <a <?php echo OIDplus::gui()->link('oidplus:system'); ?>>
  147.                                 <span id="system_title_1">ViaThinkSoft OIDplus 2.0</span><br>
  148.                                 <span id="system_title_2"><?php echo htmlentities(OIDplus::config()->getValue('system_title')); ?></span>
  149.                         </a>
  150.                 </div>
  151.         </div>
  152.  
  153.         <div id="languageBox">
  154.                 <?php
  155.  
  156.                 foreach (OIDplus::getAllPluginManifests('language') as $pluginManifest) {
  157.                         $xmldata = $pluginManifest->getRawXml();
  158.                         $flag = $xmldata->language->flag->__toString();
  159.                         $code = $xmldata->language->code->__toString();
  160.                         if ($code == OIDplus::getCurrentLang()) {
  161.                                 $class = 'lng_flag';
  162.                         } else {
  163.                                 $class = 'lng_flag picture_grayout';
  164.                         }
  165.                         echo '<img src="plugins/language/'.$code.'/'.$flag.'" alt="'.$pluginManifest->getName().'" title="'.$pluginManifest->getName().'" class="'.$class.'" id="lng_flag_'.$code.'" height="20" onclick="setLanguage(\''.$code.'\')"> ';
  166.                 }
  167.  
  168.                 ?>
  169.         </div>
  170.  
  171.         <div id="gotobox">
  172.                 <input type="text" name="goto" id="gotoedit" value="<?php echo htmlentities($static_node_id); ?>">
  173.                 <input type="button" value="Go" onclick="gotoButtonClicked()" id="gotobutton">
  174.         </div>
  175.  
  176.         <div id="oidtree" class="borderbox">
  177.                 <!-- <noscript>
  178.                         <p><b>Please enable JavaScript to use all features</b></p>
  179.                 </noscript> -->
  180.                 <?php OIDplus::menuUtils()->nonjs_menu(); ?>
  181.         </div>
  182. </div>
  183.  
  184. </body>
  185. </html>
  186. <?php
  187.  
  188. $cont = ob_get_contents();
  189. ob_end_clean();
  190.  
  191. echo $cont;
  192.