Subversion Repositories oidplus

Rev

Rev 822 | Rev 946 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 daniel-mar 1
<?php
2
 
3
/*
4
 * OIDplus 2.0
773 daniel-mar 5
 * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft
2 daniel-mar 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
 
207 daniel-mar 20
header('Content-Type:text/html; charset=UTF-8');
2 daniel-mar 21
 
207 daniel-mar 22
require_once __DIR__ . '/includes/oidplus.inc.php';
23
 
366 daniel-mar 24
set_exception_handler(array('OIDplusGui', 'html_exception_handler'));
240 daniel-mar 25
 
207 daniel-mar 26
ob_start(); // allow cookie headers to be sent
27
 
120 daniel-mar 28
OIDplus::init(true);
29
 
30
$static_node_id = isset($_REQUEST['goto']) ? $_REQUEST['goto'] : 'oidplus:system';
773 daniel-mar 31
 
775 daniel-mar 32
$static_node_id = OIDplus::prefilterQuery($static_node_id, false);
773 daniel-mar 33
 
558 daniel-mar 34
$static = OIDplus::gui()->generateContentPage($static_node_id);
120 daniel-mar 35
$static_title = $static['title'];
36
$static_icon = $static['icon'];
37
$static_content = $static['text'];
38
 
564 daniel-mar 39
if (!isset($_COOKIE['csrf_token'])) {
866 daniel-mar 40
        // TODO: It is possible that you receive a "Missing or wrong CSRF Token" warning,
41
        //       if you open a page that had a HTTPS cookie using HTTP.
42
        //       Chrome will then block "Set-Cookie" since the HTTP cookie would
43
        //       overwrite the HTTPS cookie.
564 daniel-mar 44
        // This is the main CSRF token used for AJAX.
45
        $token = OIDplus::authUtils()->genCSRFToken();
46
        OIDplus::cookieUtils()->setcookie('csrf_token', $token, 0, false);
47
        unset($token);
48
}
49
 
50
if (!isset($_COOKIE['csrf_token_weak'])) {
51
        // This CSRF token is created with SameSite=Lax and must be used
52
        // for OAuth 2.0 redirects or similar purposes.
53
        $token = OIDplus::authUtils()->genCSRFToken();
54
        OIDplus::cookieUtils()->setcookie('csrf_token_weak', $token, 0, false, 'Lax');
55
        unset($token);
56
}
57
 
362 daniel-mar 58
OIDplus::handleLangArgument();
59
 
120 daniel-mar 60
function combine_systemtitle_and_pagetitle($systemtitle, $pagetitle) {
309 daniel-mar 61
        // Please also change the function in oidplus_base.js
120 daniel-mar 62
        if ($systemtitle == $pagetitle) {
63
                return $systemtitle;
64
        } else {
309 daniel-mar 65
                return $pagetitle . ' - ' . $systemtitle;
120 daniel-mar 66
        }
5 daniel-mar 67
}
120 daniel-mar 68
 
819 daniel-mar 69
// Get theme color (color of title bar)
70
$design_plugin = OIDplus::getActiveDesignPlugin();
71
$theme_color = is_null($design_plugin) ? '' : $design_plugin->getThemeColor();
142 daniel-mar 72
 
819 daniel-mar 73
$head_elems = array();
74
$head_elems[] = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">';
75
$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
821 daniel-mar 76
if ($theme_color != '') $head_elems[] = '<meta name="theme-color" content="'.htmlentities($theme_color).'">';
819 daniel-mar 77
$head_elems[] = '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
78
$head_elems[] = '<title>'.htmlentities(combine_systemtitle_and_pagetitle(OIDplus::config()->getValue('system_title'), $static_title)).'</title>';
79
$head_elems[] = '<script src="polyfill.min.js.php"></script>';
80
$head_elems[] = OIDplus::getActiveCaptchaPlugin()->captchaDomHead();
81
$head_elems[] = '<script src="oidplus.min.js.php"></script>';
82
$head_elems[] = '<link rel="stylesheet" href="oidplus.min.css.php">';
83
$head_elems[] = '<link rel="shortcut icon" type="image/x-icon" href="favicon.ico.php">';
821 daniel-mar 84
$head_elems[] = '<link rel="canonical" href="'.htmlentities(OIDplus::canonicalURL()).'">';
819 daniel-mar 85
 
86
$plugins = OIDplus::getPagePlugins();
767 daniel-mar 87
foreach ($plugins as $plugin) {
819 daniel-mar 88
        $plugin->htmlHeaderUpdate($head_elems);
767 daniel-mar 89
}
90
 
819 daniel-mar 91
// ---
120 daniel-mar 92
 
820 daniel-mar 93
echo "<!DOCTYPE html>\n";
120 daniel-mar 94
 
820 daniel-mar 95
echo "<html lang=\"".substr(OIDplus::getCurrentLang(),0,2)."\">\n";
96
echo "<head>\n";
97
echo "\t".implode("\n\t",$head_elems)."\n";
98
echo "</head>\n";
120 daniel-mar 99
 
820 daniel-mar 100
echo "<body>\n";
101
 
819 daniel-mar 102
echo '<div id="loading" style="display:none">Loading&#8230;</div>';
215 daniel-mar 103
 
819 daniel-mar 104
echo '<div id="frames">';
105
echo '<div id="content_window" class="borderbox">';
120 daniel-mar 106
 
819 daniel-mar 107
echo '<h1 id="real_title">';
108
if ($static_icon != '') echo '<img src="'.htmlentities($static_icon).'" width="48" height="48" alt=""> ';
109
echo htmlentities($static_title).'</h1>';
110
echo '<div id="real_content">'.$static_content.'</div>';
111
if ((!isset($_SERVER['REQUEST_METHOD'])) || ($_SERVER['REQUEST_METHOD'] == 'GET')) {
112
        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>';
113
        echo '</p>';
114
}
115
echo '<br>';
532 daniel-mar 116
 
819 daniel-mar 117
echo '</div>';
126 daniel-mar 118
 
819 daniel-mar 119
echo '<div id="system_title_bar">';
126 daniel-mar 120
 
819 daniel-mar 121
echo '<div id="system_title_menu" onclick="mobileNavButtonClick(this)" onmouseenter="mobileNavButtonHover(this)" onmouseleave="mobileNavButtonHover(this)">';
122
echo '  <div id="bar1"></div>';
123
echo '  <div id="bar2"></div>';
124
echo '  <div id="bar3"></div>';
125
echo '</div>';
183 daniel-mar 126
 
819 daniel-mar 127
echo '<div id="system_title_text">';
128
echo '  <a '.OIDplus::gui()->link('oidplus:system').' id="system_title_a">';
129
echo '          <span id="system_title_logo"></span>';
822 daniel-mar 130
echo '          <span id="system_title_1">'.htmlentities(OIDplus::getEditionInfo()['vendor'].' OIDplus 2.0').'</span><br>';
819 daniel-mar 131
echo '          <span id="system_title_2">'.htmlentities(OIDplus::config()->getValue('system_title')).'</span>';
132
echo '  </a>';
133
echo '</div>';
355 daniel-mar 134
 
819 daniel-mar 135
echo '</div>';
186 daniel-mar 136
 
819 daniel-mar 137
echo OIDplus::gui()->getLanguageBox($static_node_id, true);
120 daniel-mar 138
 
819 daniel-mar 139
echo '<div id="gotobox">';
140
echo '<input type="text" name="goto" id="gotoedit" value="'.htmlentities($static_node_id).'">';
141
echo '<input type="button" value="'._L('Go').'" onclick="gotoButtonClicked()" id="gotobutton">';
142
echo '</div>';
120 daniel-mar 143
 
819 daniel-mar 144
echo '<div id="oidtree" class="borderbox">';
145
//echo '<noscript>';
146
//echo '<p><b>'._L('Please enable JavaScript to use all features').'</b></p>';
147
//echo '</noscript>';
148
OIDplus::menuUtils()->nonjs_menu();
149
echo '</div>';
150
 
151
echo '</div>';
152
 
820 daniel-mar 153
echo "\n</body>\n";
154
echo "</html>\n";
819 daniel-mar 155
 
120 daniel-mar 156
$cont = ob_get_contents();
157
ob_end_clean();
158
 
639 daniel-mar 159
OIDplus::invoke_shutdown();
160
 
821 daniel-mar 161
$plugins = OIDplus::getPagePlugins();
162
foreach ($plugins as $plugin) {
163
        $plugin->htmlPostprocess($cont);
164
}
165
 
366 daniel-mar 166
echo $cont;