forked from csev/py4e
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
100 lines (87 loc) · 2.38 KB
/
index.php
File metadata and controls
100 lines (87 loc) · 2.38 KB
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
<?php
if ( ! defined('COOKIE_SESSION') ) define('COOKIE_SESSION', true);
require_once "../tsugi/config.php";
require_once "Parsedown.php";
require_once "Parsedown_emoji.php";
require_once "../top.php";
require_once "../nav.php";
if ( ! function_exists('endsWith') ) {
function endsWith($haystack, $needle) {
// search forward starting from end minus needle length characters
return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE);
}
}
$url = $_SERVER['REQUEST_URI'];
$pieces = explode('/',$url);
$file = false;
$contents = false;
if ( $pieces >= 2 ) {
$file = $pieces[count($pieces)-1];
if ( ! endsWith($file, '.md') ) $file = false;
if ( ! $file || ! file_exists($file) ) $file = false;
}
if ( $file !== false ) {
$contents = file_get_contents($file);
$HTML_FILE = $file;
}
function x_sel($file) {
global $HTML_FILE;
$retval = 'value="'.$file.'"';
if ( strpos($HTML_FILE, $file) === 0 ) {
$retval .= " selected";
}
return $retval;
}
$OUTPUT->header();
?>
<style>
center {
padding-bottom: 10px;
}
@media print {
#chapters {
display: none;
}
}
</style>
<?php
$OUTPUT->bodyStart();
// $OUTPUT->topNav();
if ( $contents != false ) {
?>
<script>
function onSelect() {
console.log($('#chapters').val());
window.location = $('#chapters').val();
}
</script>
<div style="float:right">
<select id="chapters" onchange="onSelect();">
<option <?= x_sel("ngrok_mac.md") ?>>Using Ngrok on the Mac</option>
<option <?= x_sel("ngrok_win.md") ?>>Using Ngrok on Windows</option>
</select>
</div>
<?php
$Parsedown = new Parsedown();
$result = str_replace($parsedown_emoji_search, $parsedown_emoji_replace, $Parsedown->text($contents));
echo $Parsedown->text($result);
} else {
?>
<p>
This is a set of supplementary documentation for use with this
web site.
</p>
<ul>
<li><a href="ngrok_mac.md">Using Ngrok and the Autograder on a Macintosh</a></li>
<li><a href="ngrok_win.md">Using Ngrok and the Autograder on Windows-10</a></li>
</ul>
<p>
Note that if you are running Windows and the bash shell, NGrok does not seem to start.
Use the Windows Command line to run NGrok on Windows.
<p>
If you find a mistake in this documentation, feel free to send me a fix using
<a href="https://github.com/csev/wa4e/tree/master/md" target="_blank">Github</a>.
</p>
<?php
}
$OUTPUT->footer();