-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSource.php
93 lines (70 loc) · 2.54 KB
/
Source.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
<?php header("Content-Type: text/javascript");
include(dirname(__FILE__) . '/components/showsource.class.php');
$vs = new showsource();
if (!($vs instanceof showsource)) {
echo '[ShowSource] ShowSource class was not found.';
return false;
}
$vs->setHost('softables.tk/')
?>
css=document.body.appendChild(document.createElement("link"));
css.id="showSourceCSS";
css.rel="stylesheet";
css.href="<?php echo $vs->cssPath; ?>/showSource.css";
css.type="text/css";
m=document.body.appendChild(document.createElement("figure"));
m.id = "mSourceWindow";
<?php
$p = $_GET['p'];
if($p == "") {
$p = "http://".$vs->getHost()."/";
echo("alert(\"No page specified! usage:Source.php?p=http://www.example.com/\")");
return false;
}
$contents = "";
$contents = $vs->readFile($p);
?>
m.innerHTML=`<?php echo $vs->source($contents, $p, false); ?>`;
function closeSourceWindow(){
document.body.removeChild(document.getElementById("mSourceWindow"));
document.body.removeChild(document.getElementById("showSourceCSS"));
}
(function() {
for (var tags = ['figure', 'figcaption'], i = 0; i < tags.length; i++) {
document.createElement(tags[i]);
}
})();
(function() {
//filter IE8 and earlier which don't support the generated content
if (typeof(window.getComputedStyle) == 'undefined') {
return;
}
//get the collection of PRE elements
var pre = document.getElementsByTagName('pre');
//now iterate through the collection
for (var len = pre.length, i = 0; i < len; i++) {
//get the CODE or SAMP element inside it,
//or just in case there isn't one, continue to the next PRE
var code = pre[i].getElementsByTagName('code').item(0);
if (!code) {
code = pre[i].getElementsByTagName('samp').item(0);
if (!code) {
continue;
}
}
//create a containing DIV column (but don't append it yet)
//including aria-hidden so that ATs don't read the numbers
var column = document.createElement('div');
column.setAttribute('aria-hidden', 'true');
column.setAttribute('class', 'numbers');
//split the code by line-breaks to count the number of lines
//then for each line, add an empty span inside the column
for (var n = 0; n < code.innerHTML.split(/[\n\r]/g).length; n++) {
column.appendChild(document.createElement('span'));
}
//now append the populated column before the code element
pre[i].insertBefore(column, code);
//finally add an identifying class to the PRE to trigger the extra CSS
pre[i].className = 'line-numbers';
}
})();