forked from drlippman/IMathAS
-
Notifications
You must be signed in to change notification settings - Fork 1
/
help.php
141 lines (134 loc) · 3.31 KB
/
help.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
$dbsetup = true; //prevents connection to database
$init_skip_csrfp = true;
require_once "init_without_validate.php";
if (!isset($_GET['bare'])) {
?>
<html>
<head>
<title><?php echo $installname;?> Help</title>
<style type="text/css">
table td {
padding: 1px 10px;
}
table thead td {
font-weight: bold;
}
ul li {
margin-top: .3em;
}
span.icon {
padding-left: 5px;
padding-right: 5px;
background-color: #ff0;
color:#00d;
border: 1px solid #00f;
font-weight: bolder;
}
h1,h2,h3 {
margin-top: 1.5em;
margin-bottom: .5em;
}
h1 {
color: #00f;
}
h2,h3,h4,h5,h6 {
color: #00c;
}
div.h2 {
margin-left: 5px;
}
div.h3 {
margin-left: 10px;
}
div.h4 {
margin-left: 15px;
}
dd {
margin-bottom: .4em;
}
</style>
<link rel="stylesheet" href="<?php echo $staticroot;?>/iconfonts/style.css?v=081316" type="text/css" />
<link rel="stylesheet" href="<?php echo $staticroot;?>/tinymce4/skins/lightgray/skin.min.css?v=061416" type="text/css" />
<?php
}
//IMathAS: Reads sections of the help.html file
//(c) 2006 David Lippman
if (!isset($_GET['section']) && !isset($_GET['bare'])) {
echo "<style type=\"text/css\">\n";
echo "div.h2 {margin-left: 10px;} \n div.h3 {margin-left: 20px;} \n div.h4 {margin-left: 30px;} \n div.h5 {margin-left: 40px;} \n";
echo "</style>\n";
}
if (!isset($_GET['bare'])) {
echo "</head><body>\n";
}
if (isset($_GET['section']) && !isset($_GET['bare'])) {
echo '<div id="headerindex" class="pagetitle"><h1>'.$installname.' Help</h1></div>';
}
$indiv = false;
$intoc = false;
$ndiv = 0;
$nul = 0;
$inbody = false;
$handle = fopen("help.html", "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
$buffer = str_replace('https://yourIMathASsite', $basesiteurl, $buffer);
$buffer = str_replace('IMathAS', $installname, $buffer);
if (!$inbody) {
if (strpos($buffer,"<body")!==false) {
$inbody = true;
}
continue;
}
if (!isset($_GET['section'])) {
echo $buffer;
continue;
}
if ($indiv) {
$buffer = preg_replace('/<a\s+href\="#([^"]+)"[^>]*>/',"<a href=\"help.php?section=$1\">",$buffer);
echo $buffer;
$ndiv += substr_count($buffer,"<div");
$ndiv -= substr_count($buffer,"</div");
if ($ndiv==0) {
break;
}
} else if ($intoc) {
echo $buffer;
$nul += substr_count($buffer,"<ul");
$nul -= substr_count($buffer,"</ul");
if ($nul==0) {
echo "</ul>\n";
$intoc = false;
}
} else if (strpos($buffer,"<li><a href=\"#{$_GET['section']}\"")!==false) {
$next = fgets($handle, 4096);
if (strpos($next, "<ul>")!==false) {
$intoc = true;
$nul = 1;
echo "<ul>";
echo $buffer;
echo $next;
}
} else if (preg_match('/.*<h([1-6])\s+id="?([^">]+).*/',$buffer,$matches) && $matches[2]==$_GET['section']) {
if (!isset($_GET['bare'])) {
echo "<style>\n";
for ($i=$matches[1]+1;$i<5;$i++) {
echo "div.h$i { margin-left: " . 10*Sanitize::onlyFloat($i-$matches[1]) . "px;}\n";
}
echo "</style>\n";
}
echo "<div>\n$buffer";
$indiv = true;
$ndiv = 1;
}
}
fclose($handle);
} else {
echo "No handle";
}
if (!isset($_GET['bare'])) {
echo "</body></html>\n";
}
?>