Subversion Repositories oidplus

Rev

Rev 356 | Rev 362 | 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-2020 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>'._L('OIDplus initialization error').'</h1>';
  28.                 echo '<p>'.htmlentities($exception->getMessage(), ENT_SUBSTITUTE).'</p>';
  29.                 echo '<p>'._L('Please check file %1','<b>userdata/baseconfig/config.inc.php</b>');
  30.                 if (is_dir(__DIR__ . '/setup')) {
  31.                         echo ' '._L('or run <a href="%1">setup</a> again',OIDplus::getSystemUrl().'setup/');
  32.                 }
  33.                 echo '</p>';
  34.         } else {
  35.                 echo '<h1>'._L('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>'._L('Technical information about the problem').':</b></p>';
  39.                 echo '<pre>';
  40.                 echo get_class($exception)."\n";
  41.                 var_dump($exception->getFile());
  42.                 var_dump($exception->getLine());
  43.                 echo _L('at file %1 (line %2)',$exception->getFile(),"".$exception->getLine())."\n";
  44.                 echo _L('Stacktrace').":\n";
  45.                 echo $exception->getTraceAsString();
  46.                 echo '</pre>';
  47.         }
  48. }
  49.  
  50. ob_start(); // allow cookie headers to be sent
  51.  
  52. OIDplus::init(true);
  53.  
  54. $static_node_id = isset($_REQUEST['goto']) ? $_REQUEST['goto'] : 'oidplus:system';
  55. $static = OIDplus::gui()::generateContentPage($static_node_id);
  56. $static_title = $static['title'];
  57. $static_icon = $static['icon'];
  58. $static_content = $static['text'];
  59.  
  60. function combine_systemtitle_and_pagetitle($systemtitle, $pagetitle) {
  61.         // Please also change the function in oidplus_base.js
  62.         if ($systemtitle == $pagetitle) {
  63.                 return $systemtitle;
  64.         } else {
  65.                 return $pagetitle . ' - ' . $systemtitle;
  66.         }
  67. }
  68.  
  69. $sysid_oid = OIDplus::getSystemId(true);
  70. if (!$sysid_oid) $sysid_oid = 'unknown'; // do not translate
  71. header('X-OIDplus-SystemID:'.$sysid_oid);
  72.  
  73. $sys_url = OIDplus::getSystemUrl();
  74. header('X-OIDplus-SystemURL:'.$sys_url);
  75.  
  76. $sys_ver = OIDplus::getVersion();
  77. if (!$sys_ver) $sys_ver = 'unknown'; // do not translate
  78. header('X-OIDplus-SystemVersion:'.$sys_ver);
  79.  
  80. $sys_install_type = OIDplus::getInstallType();
  81. header('X-OIDplus-SystemInstallType:'.$sys_install_type);
  82.  
  83. $sys_title = OIDplus::config()->getValue('system_title');
  84. header('X-OIDplus-SystemTitle:'.$sys_title);
  85.  
  86. if (class_exists('OIDplusPageAdminColors')) {
  87.         $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);
  88. } else {
  89.         $css = 'oidplus.min.css.php';
  90. }
  91.  
  92. $js = 'oidplus.min.js.php';
  93.  
  94. ?><!DOCTYPE html>
  95. <html lang="en">
  96.  
  97. <head>
  98.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  99.         <meta name="OIDplus-SystemID" content="<?php echo htmlentities($sysid_oid); ?>">
  100.         <meta name="OIDplus-SystemURL" content="<?php echo htmlentities($sys_url); ?>">
  101.         <meta name="OIDplus-SystemVersion" content="<?php echo htmlentities($sys_ver); ?>">
  102.         <meta name="OIDplus-SystemInstallType" content="<?php echo htmlentities($sys_install_type); ?>">
  103.         <meta name="OIDplus-SystemTitle" content="<?php echo htmlentities($sys_title); /* Do not remove. This meta tag is acessed by oidplus_base.js */ ?>">
  104.         <meta name="theme-color" content="#A9DCF0">
  105.         <meta name="viewport" content="width=device-width, initial-scale=1.0">
  106.  
  107.         <title><?php echo combine_systemtitle_and_pagetitle(OIDplus::config()->getValue('system_title'), $static_title); ?></title>
  108.  
  109.         <script src="<?php echo htmlentities($js); ?>"></script>
  110.  
  111.         <link rel="stylesheet" href="<?php echo htmlentities($css); ?>">
  112.         <link rel="shortcut icon" type="image/x-icon" href="favicon.ico.php">
  113. </head>
  114.  
  115. <body>
  116.  
  117. <div id="frames">
  118.         <div id="content_window" class="borderbox">
  119.                 <?php
  120.                 $static_content = preg_replace_callback(
  121.                         '|<a\s([^>]*)href="mailto:([^"]+)"([^>]*)>([^<]*)</a>|ismU',
  122.                         function ($treffer) {
  123.                                 $email = $treffer[2];
  124.                                 $text = $treffer[4];
  125.                                 return OIDplus::mailUtils()->secureEmailAddress($email, $text, 1); // AntiSpam
  126.                         }, $static_content);
  127.  
  128.                 echo '<h1 id="real_title">';
  129.                 if ($static_icon != '') echo '<img src="'.htmlentities($static_icon).'" width="48" height="48" alt=""> ';
  130.                 echo htmlentities($static_title).'</h1>';
  131.                 echo '<div id="real_content">'.$static_content.'</div>';
  132.                 if ((!isset($_SERVER['REQUEST_METHOD'])) || ($_SERVER['REQUEST_METHOD'] == 'GET')) {
  133.                         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>';
  134.                         echo '</p>';
  135.                 }
  136.                 echo '<br>';
  137.                 ?>
  138.         </div>
  139.  
  140.         <div id="system_title_bar">
  141.                 <?php
  142.                 echo '<div id="system_title_menu" onclick="mobileNavButtonClick(this)" onmouseenter="mobileNavButtonHover(this)" onmouseleave="mobileNavButtonHover(this)">';
  143.                 echo '  <div id="bar1"></div>';
  144.                 echo '  <div id="bar2"></div>';
  145.                 echo '  <div id="bar3"></div>';
  146.                 echo '</div>';
  147.                 echo '';
  148.                 echo '<div id="system_title_text">';
  149.                 echo '  <a '.OIDplus::gui()->link('oidplus:system').'>';
  150.                 echo '          <span id="system_title_1">'._L('ViaThinkSoft OIDplus 2.0').'</span><br>';
  151.                 echo '          <span id="system_title_2">'.htmlentities(OIDplus::config()->getValue('system_title')).'</span>';
  152.                 echo '  </a>';
  153.                 echo '</div>';
  154.                 ?>
  155.         </div>
  156.  
  157.         <div id="languageBox">
  158.                 <?php
  159.  
  160.                 if (isset($_GET['lang'])) {
  161.                         // The "?lang=" argument is only for NoScript-Browsers/SearchEngines
  162.                         // In case someone who has JavaScript clicks a ?lang= link, they should get
  163.                         // the page in that language, but the cookie must be set, otherwise
  164.                         // the menu and other stuff would be in their cookie-based-language and not the
  165.                         // argument-based-language.
  166.                         $cookie_path = OIDplus::getSystemUrl(true);
  167.                         if (empty($cookie_path)) $cookie_path = '/';
  168.                         setcookie('LANGUAGE', $_GET['lang'], 0, $cookie_path, '', false, false/*HttpOnly off, because JavaScript also needs translation*/);
  169.                 } else if (isset($_POST['lang'])) {
  170.                         $cookie_path = OIDplus::getSystemUrl(true);
  171.                         if (empty($cookie_path)) $cookie_path = '/';
  172.                         setcookie('LANGUAGE', $_POST['lang'], 0, $cookie_path, '', false, false/*HttpOnly off, because JavaScript also needs translation*/);
  173.                 }
  174.  
  175.                 $langbox_entries = array();
  176.                 $non_default_languages = 0;
  177.                 foreach (OIDplus::getAllPluginManifests('language') as $pluginManifest) {
  178.                         $xmldata = $pluginManifest->getRawXml();
  179.                         $flag = $xmldata->language->flag->__toString();
  180.                         $code = $xmldata->language->code->__toString();
  181.                         if ($code != OIDplus::DEFAULT_LANGUAGE) $non_default_languages++;
  182.                         if ($code == OIDplus::getCurrentLang()) {
  183.                                 $class = 'lng_flag';
  184.                         } else {
  185.                                 $class = 'lng_flag picture_ghost';
  186.                         }
  187.                         $langbox_entries[] = '<a onclick="setLanguage(\''.$code.'\'); return false" href="?lang='.$code.'&amp;goto='.$static_node_id.'"><img src="plugins/language/'.$code.'/'.$flag.'" alt="'.$pluginManifest->getName().'" title="'.$pluginManifest->getName().'" class="'.$class.'" id="lng_flag_'.$code.'" height="20"></a> ';
  188.                 }
  189.                 if ($non_default_languages > 0) {
  190.                         echo implode("\n\t\t",$langbox_entries);
  191.                 }
  192.  
  193.                 ?>
  194.         </div>
  195.  
  196.         <div id="gotobox">
  197.                 <?php
  198.                 echo '<input type="text" name="goto" id="gotoedit" value="'.htmlentities($static_node_id).'">';
  199.                 echo '<input type="button" value="'._L('Go').'" onclick="gotoButtonClicked()" id="gotobutton">';
  200.                 ?>
  201.         </div>
  202.  
  203.         <div id="oidtree" class="borderbox">
  204.                 <!-- <noscript>
  205.                         <p><b><?php echo _L('Please enable JavaScript to use all features'); ?></b></p>
  206.                 </noscript> -->
  207.                 <?php OIDplus::menuUtils()->nonjs_menu(); ?>
  208.         </div>
  209. </div>
  210.  
  211. </body>
  212. </html>
  213. <?php
  214.  
  215. $cont = ob_get_contents();
  216. ob_end_clean();
  217.  
  218. echo $cont;