-
Notifications
You must be signed in to change notification settings - Fork 38
/
index.php
119 lines (116 loc) · 3.95 KB
/
index.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
<?php
/**
* This file is part of Leash (Browser Shell)
* Copyright (C) 2013-2023 Jakub Jankiewicz <http://jcubic.pl/me>
*
* Released under the MIT license
*
*/
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
ini_set('display_errors', 'On');
require('lib/Service.php');
$leash = new Leash('config.json', getcwd());
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) &&
$_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
require_once('lib/json-rpc.php');
if ($leash->debug()) {
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
ini_set('display_errors', 'On');
}
echo handle_json_rpc($leash);
exit;
}
?><!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Leash Shell</title>
<meta name="Description" content=""/>
<link rel="shortcut icon" href="favicon.ico"/>
<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link href="<?= with_hash('css/jquery.terminal.css') ?>" rel="stylesheet"/>
<link href="<?= with_hash('css/style.css') ?>" rel="stylesheet"/>
<style>
/* some styles before I move them to style.css */
</style>
<meta name="viewport" content="width=device-width, initial-scale=1.0, interactive-widget=resizes-content"/>
</head>
<body>
<div id="splash">
<div>
<pre>
__ _______ ______ __
/ / / __/ _ | / __/ // /
/ /__/ _// __ |_\ \/ _ /
/____/___/_/ |_/___/_//_/
<span>[ LOADING ]</span>
</pre>
</div>
</div>
<div id="shell" style="display:none"></div>
<?php if ($leash->debug()) { ?>
<script src="lib/jquery-3.7.0.js"></script>
<?php } else { ?>
<script src="lib/jquery-3.7.0.min.js"></script>
<?php } ?>
<script src="<?= with_hash('lib/json-rpc.js') ?>"></script>
<script src="<?= with_hash('lib/wcwidth.js') ?>"></script>
<?php if ($leash->debug()) { ?>
<script src="<?= with_hash('lib/jquery.terminal-src.js') ?>"></script>
<?php } else { ?>
<script src="<?= with_hash('lib/jquery.terminal.min.js') ?>"></script>
<?php } ?>
<script src="<?= with_hash('lib/unix_formatting.js') ?>"></script>
<script src="<?= with_hash('lib/jquery.mousewheel-min.js') ?>"></script>
<script src="<?= with_hash('lib/browser.js') ?>"></script>
<script src="<?= with_hash('lib/optparse.js') ?>"></script>
<script src="<?= with_hash('lib/jquery.ba-hashchange.min.js') ?>"></script>
<script src="<?= with_hash('lib/keyboardeventKeyPolyfill.js') ?>"></script>
<script src="<?= with_hash('lib/sysend.js') ?>"></script>
<?php if ($leash->debug()) { ?>
<script src="<?= with_hash('leash-src.js') ?>"></script>
<?php } else { ?>
<script src="<?= with_hash('leash.min.js') ?>"></script>
<?php } ?>
<script>
keyboardeventKeyPolyfill.polyfill();
var d = $.Deferred();
$.leash = d.promise();
$(function() {
$('#shell').css({
overflow: 'auto'
}).leash().then(function(leash) {
$('#splash').hide();
d.resolve(leash);
// terminal is created after async call so we need to get terminal
// instance in a promise otherwise it will be created here.
var terminal = $('#shell').show().terminal();
var $win = $(window);
$win.resize(function() {
var height = $win.height();
terminal.innerHeight(height);
}).resize();
terminal.resize();
});
});
</script>
<?php
$dir = 'lib/apps/';
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (is_dir($dir . $file) && file_exists($dir . $file . '/init.js')) {
echo ' <script src="' . with_hash($dir. $file . '/init.js') . '"></script>';
}
}
closedir($dh);
}
}
if (file_exists('init.js')) {
echo '<script src="' . with_hash('init.js') . '"></script>';
}
?>
</body>
</html>