Subversion Repositories oidplus

Rev

Rev 356 | Rev 362 | 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
360 daniel-mar 5
 * Copyright 2019-2020 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
 
240 daniel-mar 24
set_exception_handler('html_exception_handler');
25
function html_exception_handler($exception) {
26
        if ($exception instanceof OIDplusConfigInitializationException) {
360 daniel-mar 27
                echo '<h1>'._L('OIDplus initialization error').'</h1>';
349 daniel-mar 28
                echo '<p>'.htmlentities($exception->getMessage(), ENT_SUBSTITUTE).'</p>';
360 daniel-mar 29
                echo '<p>'._L('Please check file %1','<b>userdata/baseconfig/config.inc.php</b>');
240 daniel-mar 30
                if (is_dir(__DIR__ . '/setup')) {
360 daniel-mar 31
                        echo ' '._L('or run <a href="%1">setup</a> again',OIDplus::getSystemUrl().'setup/');
240 daniel-mar 32
                }
33
                echo '</p>';
34
        } else {
360 daniel-mar 35
                echo '<h1>'._L('OIDplus error').'</h1>';
242 daniel-mar 36
                // ENT_SUBSTITUTE because ODBC drivers might return ANSI instead of UTF-8 stuff
37
                echo '<p>'.htmlentities($exception->getMessage(), ENT_SUBSTITUTE).'</p>';
360 daniel-mar 38
                echo '<p><b>'._L('Technical information about the problem').':</b></p>';
240 daniel-mar 39
                echo '<pre>';
40
                echo get_class($exception)."\n";
360 daniel-mar 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";
240 daniel-mar 45
                echo $exception->getTraceAsString();
46
                echo '</pre>';
47
        }
48
}
49
 
207 daniel-mar 50
ob_start(); // allow cookie headers to be sent
51
 
120 daniel-mar 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) {
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
 
227 daniel-mar 69
$sysid_oid = OIDplus::getSystemId(true);
360 daniel-mar 70
if (!$sysid_oid) $sysid_oid = 'unknown'; // do not translate
120 daniel-mar 71
header('X-OIDplus-SystemID:'.$sysid_oid);
72
 
227 daniel-mar 73
$sys_url = OIDplus::getSystemUrl();
120 daniel-mar 74
header('X-OIDplus-SystemURL:'.$sys_url);
75
 
76
$sys_ver = OIDplus::getVersion();
360 daniel-mar 77
if (!$sys_ver) $sys_ver = 'unknown'; // do not translate
120 daniel-mar 78
header('X-OIDplus-SystemVersion:'.$sys_ver);
79
 
170 daniel-mar 80
$sys_install_type = OIDplus::getInstallType();
81
header('X-OIDplus-SystemInstallType:'.$sys_install_type);
82
 
257 daniel-mar 83
$sys_title = OIDplus::config()->getValue('system_title');
120 daniel-mar 84
header('X-OIDplus-SystemTitle:'.$sys_title);
85
 
142 daniel-mar 86
if (class_exists('OIDplusPageAdminColors')) {
286 daniel-mar 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);
142 daniel-mar 88
} else {
89
        $css = 'oidplus.min.css.php';
90
}
91
 
218 daniel-mar 92
$js = 'oidplus.min.js.php';
93
 
120 daniel-mar 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); ?>">
170 daniel-mar 102
        <meta name="OIDplus-SystemInstallType" content="<?php echo htmlentities($sys_install_type); ?>">
215 daniel-mar 103
        <meta name="OIDplus-SystemTitle" content="<?php echo htmlentities($sys_title); /* Do not remove. This meta tag is acessed by oidplus_base.js */ ?>">
120 daniel-mar 104
        <meta name="theme-color" content="#A9DCF0">
105
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
106
 
257 daniel-mar 107
        <title><?php echo combine_systemtitle_and_pagetitle(OIDplus::config()->getValue('system_title'), $static_title); ?></title>
120 daniel-mar 108
 
218 daniel-mar 109
        <script src="<?php echo htmlentities($js); ?>"></script>
215 daniel-mar 110
 
142 daniel-mar 111
        <link rel="stylesheet" href="<?php echo htmlentities($css); ?>">
314 daniel-mar 112
        <link rel="shortcut icon" type="image/x-icon" href="favicon.ico.php">
120 daniel-mar 113
</head>
114
 
115
<body>
116
 
117
<div id="frames">
126 daniel-mar 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];
250 daniel-mar 125
                                return OIDplus::mailUtils()->secureEmailAddress($email, $text, 1); // AntiSpam
126 daniel-mar 126
                        }, $static_content);
127
 
128
                echo '<h1 id="real_title">';
127 daniel-mar 129
                if ($static_icon != '') echo '<img src="'.htmlentities($static_icon).'" width="48" height="48" alt=""> ';
126 daniel-mar 130
                echo htmlentities($static_title).'</h1>';
131
                echo '<div id="real_content">'.$static_content.'</div>';
315 daniel-mar 132
                if ((!isset($_SERVER['REQUEST_METHOD'])) || ($_SERVER['REQUEST_METHOD'] == 'GET')) {
360 daniel-mar 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>';
126 daniel-mar 134
                        echo '</p>';
135
                }
136
                echo '<br>';
137
                ?>
138
        </div>
139
 
120 daniel-mar 140
        <div id="system_title_bar">
360 daniel-mar 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
                ?>
185 daniel-mar 155
        </div>
183 daniel-mar 156
 
355 daniel-mar 157
        <div id="languageBox">
158
                <?php
159
 
360 daniel-mar 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;
355 daniel-mar 177
                foreach (OIDplus::getAllPluginManifests('language') as $pluginManifest) {
178
                        $xmldata = $pluginManifest->getRawXml();
179
                        $flag = $xmldata->language->flag->__toString();
180
                        $code = $xmldata->language->code->__toString();
360 daniel-mar 181
                        if ($code != OIDplus::DEFAULT_LANGUAGE) $non_default_languages++;
355 daniel-mar 182
                        if ($code == OIDplus::getCurrentLang()) {
183
                                $class = 'lng_flag';
184
                        } else {
356 daniel-mar 185
                                $class = 'lng_flag picture_ghost';
355 daniel-mar 186
                        }
360 daniel-mar 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> ';
355 daniel-mar 188
                }
360 daniel-mar 189
                if ($non_default_languages > 0) {
190
                        echo implode("\n\t\t",$langbox_entries);
191
                }
355 daniel-mar 192
 
193
                ?>
194
        </div>
195
 
186 daniel-mar 196
        <div id="gotobox">
360 daniel-mar 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
                ?>
186 daniel-mar 201
        </div>
202
 
120 daniel-mar 203
        <div id="oidtree" class="borderbox">
122 daniel-mar 204
                <!-- <noscript>
360 daniel-mar 205
                        <p><b><?php echo _L('Please enable JavaScript to use all features'); ?></b></p>
122 daniel-mar 206
                </noscript> -->
250 daniel-mar 207
                <?php OIDplus::menuUtils()->nonjs_menu(); ?>
120 daniel-mar 208
        </div>
209
</div>
210
 
211
</body>
212
</html>
213
<?php
214
 
215
$cont = ob_get_contents();
216
ob_end_clean();
217
 
360 daniel-mar 218
echo $cont;