-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdisplay.php
124 lines (113 loc) · 4.26 KB
/
display.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
<?php
$file = $_GET['file'] ?? die('Wrong filename');
list($dir, $file) = preg_split('[\/]', $file, 2);
if (isset($file)) {
$file = $dir . DIRECTORY_SEPARATOR . $file . '.php';
} else {
$file = $dir . '.php';
}
$path = realpath(__DIR__ . DIRECTORY_SEPARATOR . $file);
if (strpos($path, __DIR__) !== 0) {
die('Wrong path to file');
}
if (!is_file(__DIR__ . DIRECTORY_SEPARATOR . $file)) {
die('Wrong filename');
}
$code = highlight_file($file, true);
ob_start();
{
require $file;
$result = ob_get_contents();
}
ob_end_clean();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Examples of code</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css"
integrity="sha256-fmMNkMcjSw3xcp9iuPnku/ryk9kaWgrEbfJfKmdZ45o=" crossorigin="anonymous"/>
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css"
integrity="sha256-uXf0U0UCIqBp2J3S53b28h+fpC9uFcA8f+b/NNmiwVk=" crossorigin="anonymous"/>
<style>
.panel-body code {
display: block;
padding: 8px;
background-color: #f5f5f5;
border: 1px solid #ccc;
border-radius: 4px;
}
</style>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#examples-navbar"
aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Homepage</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="examples-navbar">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">List of examples <span class="caret"></span></a>
<ul class="dropdown-menu list-group">
<?php
include 'template/menu.php'; ?>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Code
<a class="btn btn-default btn-xs pull-right" href="/<?= $file ?>" role="button">
<span class="glyphicon glyphicon-play" aria-hidden="true"></span>
</a>
</h3>
</div>
<div class="panel-body">
<?= $code ?>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Result</h3>
<a href=""></a>
</div>
<div class="panel-body">
<?= $result ?>
</div>
</div>
</div>
<div class="container">
<footer class="row text-center text-muted">
© 2016 - <?= date('Y') ?> <a href="https://www.nixsolutions.com/">NIX</a><br/>
© 2016 - <?= date('Y') ?> <a href="https://anton.shevchuk.name/">Anton Shevchuk</a>
</footer>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS"
crossorigin="anonymous"></script>
</body>
</html>