Subversion Repositories oidplus

Rev

Rev 218 | Rev 236 | 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
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
 
207 daniel-mar 20
header('Content-Type:text/html; charset=UTF-8');
2 daniel-mar 21
 
208 daniel-mar 22
// Before we do ANYTHING, check for dependencies! Do not include anything (except the GMP supplement) yet.
120 daniel-mar 23
 
207 daniel-mar 24
$missing_dependencies = array();
120 daniel-mar 25
 
208 daniel-mar 26
include_once __DIR__ . '/includes/gmp_supplement.inc.php';
27
 
135 daniel-mar 28
if (!function_exists('gmp_init')) {
208 daniel-mar 29
        // GMP Required for includes/uuid_functions.inc.php
30
        //                  includes/ipv6_functions.inc.php
31
        //                  plugins/adminPages/400_oidinfo_export/oidinfo_api.inc.php (if GMP is not available, BC will be used)
32
        // Note that gmp_supplement.inc.php will implement the GMP functions if BCMath is present.
215 daniel-mar 33
        // This is the reason why we use function_exists('gmp_init') instead of extension_loaded('gmp')
208 daniel-mar 34
        $missing_dependencies[] = 'GMP (Install it using <code>sudo aptitude update && sudo aptitude install php-gmp && sudo service apache2 restart</code> on Linux systems.)' .
35
                                  '<br>or alternatively<br>' .
36
                                  'BCMath (Install it using <code>sudo aptitude update && sudo aptitude install php-bcmath && sudo service apache2 restart</code> on Linux systems.)';
135 daniel-mar 37
}
38
 
138 daniel-mar 39
if (!function_exists('mb_substr')) {
207 daniel-mar 40
        // Required for includes/classes/OIDplusSessionHandler.class.php
41
        //              includes/oid_utils.inc.php
42
        //              3p/minify/path-converter/Converter.php
43
        //              3p/0xbb/Sha3.class.php
208 daniel-mar 44
        $missing_dependencies[] = 'MBString (Install it using <code>sudo aptitude update && sudo aptitude install php-mbstring && sudo service apache2 restart</code> on Linux systems.)';
138 daniel-mar 45
}
46
 
207 daniel-mar 47
if (count($missing_dependencies) >= 1) {
48
        echo '<h1>OIDplus error</h1>';
49
        echo '<p>The following PHP extensions need to be installed in order to run OIDplus.</p>';
50
        echo '<ul>';
51
        foreach ($missing_dependencies as $dependency) {
52
                echo '<li>'.$dependency.'</li>';
53
        }
54
        echo '</ul>';
55
        die();
56
}
57
 
58
// Now we can continue!
59
 
60
require_once __DIR__ . '/includes/oidplus.inc.php';
61
 
62
ob_start(); // allow cookie headers to be sent
63
 
120 daniel-mar 64
OIDplus::init(true);
65
 
66
$static_node_id = isset($_REQUEST['goto']) ? $_REQUEST['goto'] : 'oidplus:system';
67
$static = OIDplus::gui()::generateContentPage($static_node_id);
68
$static_title = $static['title'];
69
$static_icon = $static['icon'];
70
$static_content = $static['text'];
71
 
72
function combine_systemtitle_and_pagetitle($systemtitle, $pagetitle) {
73
        if ($systemtitle == $pagetitle) {
74
                return $systemtitle;
75
        } else {
76
                return $systemtitle . ' - ' . $pagetitle;
77
        }
5 daniel-mar 78
}
120 daniel-mar 79
 
227 daniel-mar 80
$sysid_oid = OIDplus::getSystemId(true);
120 daniel-mar 81
if (!$sysid_oid) $sysid_oid = 'unknown';
82
header('X-OIDplus-SystemID:'.$sysid_oid);
83
 
227 daniel-mar 84
$sys_url = OIDplus::getSystemUrl();
120 daniel-mar 85
header('X-OIDplus-SystemURL:'.$sys_url);
86
 
87
$sys_ver = OIDplus::getVersion();
88
if (!$sys_ver) $sys_ver = 'unknown';
89
header('X-OIDplus-SystemVersion:'.$sys_ver);
90
 
170 daniel-mar 91
$sys_install_type = OIDplus::getInstallType();
92
header('X-OIDplus-SystemInstallType:'.$sys_install_type);
93
 
120 daniel-mar 94
$sys_title = OIDplus::config()->systemTitle();
95
header('X-OIDplus-SystemTitle:'.$sys_title);
96
 
142 daniel-mar 97
if (class_exists('OIDplusPageAdminColors')) {
98
        $css = 'oidplus.min.css.php?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);
99
} else {
100
        $css = 'oidplus.min.css.php';
101
}
102
 
218 daniel-mar 103
$js = 'oidplus.min.js.php';
104
 
120 daniel-mar 105
?><!DOCTYPE html>
106
<html lang="en">
107
 
108
<head>
109
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
110
        <meta name="OIDplus-SystemID" content="<?php echo htmlentities($sysid_oid); ?>">
111
        <meta name="OIDplus-SystemURL" content="<?php echo htmlentities($sys_url); ?>">
112
        <meta name="OIDplus-SystemVersion" content="<?php echo htmlentities($sys_ver); ?>">
170 daniel-mar 113
        <meta name="OIDplus-SystemInstallType" content="<?php echo htmlentities($sys_install_type); ?>">
215 daniel-mar 114
        <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 115
        <meta name="theme-color" content="#A9DCF0">
116
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
117
 
118
        <title><?php echo combine_systemtitle_and_pagetitle(OIDplus::config()->systemTitle(), $static_title); ?></title>
119
 
218 daniel-mar 120
        <script src="<?php echo htmlentities($js); ?>"></script>
215 daniel-mar 121
 
142 daniel-mar 122
        <link rel="stylesheet" href="<?php echo htmlentities($css); ?>">
120 daniel-mar 123
        <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
124
</head>
125
 
126
<body>
127
 
128
<div id="frames">
126 daniel-mar 129
        <div id="content_window" class="borderbox">
130
                <?php
131
                $static_content = preg_replace_callback(
132
                        '|<a\s([^>]*)href="mailto:([^"]+)"([^>]*)>([^<]*)</a>|ismU',
133
                        function ($treffer) {
134
                                $email = $treffer[2];
135
                                $text = $treffer[4];
136
                                return secure_email($email, $text, 1); // AntiSpam
137
                        }, $static_content);
138
 
139
                echo '<h1 id="real_title">';
127 daniel-mar 140
                if ($static_icon != '') echo '<img src="'.htmlentities($static_icon).'" width="48" height="48" alt=""> ';
126 daniel-mar 141
                echo htmlentities($static_title).'</h1>';
142
                echo '<div id="real_content">'.$static_content.'</div>';
143
                if ($_SERVER['REQUEST_METHOD'] == 'GET') {
144
                        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>';
145
                        echo '</p>';
146
                }
147
                echo '<br>';
148
                ?>
149
        </div>
150
 
120 daniel-mar 151
        <div id="system_title_bar">
122 daniel-mar 152
                <div id="system_title_menu" onclick="mobileNavButtonClick(this)" onmouseenter="mobileNavButtonHover(this)" onmouseleave="mobileNavButtonHover(this)">
120 daniel-mar 153
                        <div id="bar1"></div>
154
                        <div id="bar2"></div>
155
                        <div id="bar3"></div>
156
                </div>
157
 
122 daniel-mar 158
                <div id="system_title_text">
120 daniel-mar 159
                        <a <?php echo oidplus_link('oidplus:system'); ?>>
160
                                <span id="system_title_1">ViaThinkSoft OIDplus 2.0</span><br>
161
                                <span id="system_title_2"><?php echo htmlentities(OIDplus::config()->systemTitle()); ?></span>
162
                        </a>
163
                </div>
185 daniel-mar 164
        </div>
183 daniel-mar 165
 
186 daniel-mar 166
        <div id="gotobox">
167
                <input type="text" name="goto" id="gotoedit" value="<?php echo htmlentities($static_node_id); ?>">
168
                <input type="button" value="Go" onclick="gotoButtonClicked()" id="gotobutton">
169
        </div>
170
 
120 daniel-mar 171
        <div id="oidtree" class="borderbox">
122 daniel-mar 172
                <!-- <noscript>
120 daniel-mar 173
                        <p><b>Please enable JavaScript to use all features</b></p>
122 daniel-mar 174
                </noscript> -->
120 daniel-mar 175
                <?php OIDplusTree::nonjs_menu(); ?>
176
        </div>
177
</div>
178
 
179
</body>
180
</html>
181
<?php
182
 
183
$cont = ob_get_contents();
184
ob_end_clean();
185
 
186
echo $cont;