-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathshell.php
300 lines (247 loc) · 10.5 KB
/
shell.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
<?php
session_start();
if ($_SESSION['id_rol'] != 0) {
header("location: ../../");
}
$active_tablero = "";
$active_allowlist = "";
$active_permisos = "";
$active_admin = "";
$active_mundo = "";
$active_backups = "";
$active_propiedades = "";
$active_logs = "active";
$title = "Minecraft SRV | Simple Invoice";
$accion = (isset($_POST['accion'])) ? $_POST['accion'] : "";
$error = array();
switch ($accion) {
// REalizar Copia de Serguridad
case 'btnCopia':
$txtCopia = shell_exec("zip -r dirname/minecraftbe/panel/config/$(date +%d.%m.%Y_%H\:%M\:%S_servername).zip dirname/minecraftbe");
$btnaccion = 'Respaldo o copia de seguridad manual realizado con exito';
unset($_POST);
unset($_REQUEST);
header("Location: " . $_SERVER['PHP_SELF']);
break;
}
include "panel/includes/scripts.php";
function listadoDirectorio($directorio){
$listado = scandir($directorio);
unset($listado[array_search('.', $listado, true)]);
unset($listado[array_search('..', $listado, true)]);
if (count($listado) < 1) {
return;
}
foreach($listado as $elemento){
if(!is_dir($directorio.'/'.$elemento)) {
echo "<li><i class='fas fa-minus'></i> <a href='$directorio/$elemento'>$elemento</a></li>";
}
if(is_dir($directorio.'/'.$elemento)) {
echo '<li class="open-dropdown"><i class="fas fa-plus"></i> '.$elemento.'</li>';
echo '<ul class="dropdown d-none">';
listadoDirectorio($directorio.'/'.$elemento);
echo '</ul>';
}
}
}
if ($_GET['stop']) {
# This code will run if ?run=true is set.
exec("dirname/minecraftbe/servername/stop.sh");
}
if ($_GET['run']) {
# This code will run if ?run=true is set.
exec("dirname/minecraftbe/servername/start.sh");
}
if ($_GET['restart']) {
# This code will run if ?run=true is set.
exec("dirname/minecraftbe/servername/restart.sh");
}
?>
<!doctype html>
<html lang="es">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Consola</title>
<?php ?>
<script>
$(document).ready(function(){
$(".open-dropdown").click(function(){
$(this).next( "ul.dropdown" ).toggleClass('d-none');
});
});
</script>
</head>
<body>
<div class="container">
<form action="shell.php" method="post" enctype="multipart/form-data">
<div class="card text-center text-white bg-secondary">
<div class="card-header">
<b>Ejecutar Acciones</b><br>
</div>
<div class="card-body">
<h5 class="card-title">Control del Servidor</h5>
<p class="card-text text-warning">
<label for="validationServer01">Shell</label>
<input type="text" name="command" value="" class="form-control" id="validationServer01" aria-describedby="validationServer01Feedback" required>
<div id="validationServer01Feedback" class="invalid-feedback">
</div>
<button value="btnIniciar" class="btn btn-success" type="submit" name="accion"><i class="fas fa-play"></i> Iniciar</button>
<div class="form-group">
<h5 class="text-warning text-left">
<?php
if (empty($_POST['command'])) {
} else {
$command = $_POST['command'];
echo "<pre>";
echo shell_exec($command);
echo "</pre>";
}
?>
</h5>
</div>
</p>
</div>
<div class="card-footer text-muted">
<a href="panel/mundo/" value="btnCerrar" class="btn btn-danger" type="submit" name="accion"><i class="fas fa-close"></i> Cerrar Consola</a>
<a href="archivos.php" value="btnCerrar" class="btn btn-warning" type="submit" name="accion"><i class="fas fa-close"></i> Gestión Archivos</a>
</div>
<div class="card-footer text-muted">
<a href="?stop=true" class="btn btn-danger" type="submit" name="stop"><i class="fas fa-stop"></i> Detener</a>
<a href="?run=true" class="btn btn-success" type="submit" name="run"><i class="fas fa-play"></i> Iniciar</a>
<a href="?restart=true" class="btn btn-info" type="submit" name="restart"><i class="fas fa-redo-alt"></i> Reiniciar</a>
<!-- This link will add ?run=true to your URL, myfilename.php?run=true
<a href="">Reiniciar</a>
-->
</div>
</div>
</form>
<div class="card-footer text-muted">
<div class="container-fluid"><!-- Inicio Respaldo web -->
<div class="row justify-content-md-center">
<div class="col-md-auto">
<form method="POST" action="" enctype="multipart/form-data">
<button value="btnCopia" class="btn btn-secondary justify-content-md-center" type="submit" name="accion"><i class="fas fa-folder-plus"></i> Realizar Respaldo de todo el Servidor</button>
<?php
if (empty($btnaccion)) {
echo '';
} else {
echo $btnaccion;
}
?>
</form>
</div>
</div>
</div> <!-- Fin Respaldos Automaticos mundo -->
</div>
<br>
<!--tabla-->
<div class="panel panel-primary">
<div class="panel-heading">
<!--<h6 class="panel-title">Respaldos Disponibles</h6>-->
</div>
<div class="panel-body">
<button type="button" class="btn btn-primary" id="">Archivos de Configuración</button>
<form method="POST" action="panel/mundo/CargarFicherosConfi.php" enctype="multipart/form-data">
<div class="form-group">
<label class="btn btn-outline-secondary" for="my-file-selector">
<input required="" type="file" name="file" id="exampleInputFile">
<button class="btn btn-info" type="submit"><i class="fas fa-upload"></i> Cargar Fichero</button>
</label>
</div>
</form>
<table id="tablaRespaldos" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th width="3%" scope="col">#</th>
<!--<th width="7%" scope="col">#</th>-->
<th scope="col">Nombre Archivo</th>
<th width="26%" scope="col">Acciones</th>
<!--<th width="10%" scope="col">Acciones</th>-->
</tr>
</thead>
<tbody id="respaldos">
<?php
$archivos = scandir("config");
$num = 0;
for ($i = 2; $i < count($archivos); $i++) {
$num++;
?>
<p>
</p>
<tr>
<th scope="row"><?php echo $num; ?></th>
<td><?php echo $archivos[$i]; ?></td>
<td>
<a href="config/<?php echo $archivos[$i]; ?>" download="<?php echo $archivos[$i]; ?>" data-toggle="tooltip" data-placement="top" title="Descargar" type="submit" class="btn btn-info btn-sm" name="accion"><i class="fas fa-download"></i></a>
<form style="display: inline-block" method="POST" action="panel/propiedades/ver_archivo.php">
<input type="hidden" name="log" value="<?php echo $archivos[$i] ?>">
<input type="hidden" name="num" value="<?php echo $num ?>">
<button value="log" data-toggle="tooltip" data-placement="top" title="Ver Archivo # <?php echo $num; ?>" type="submit" class="btn btn-warning btn-sm" name="accion"><i class="fas fa-eye"></i></button>
</form>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<br>
<!--<h6 class="panel-title">Respaldos Disponibles</h6>-->
<div class="panel-body">
<button type="button" class="btn btn-primary" id="botonLogs">Archivos del Servidor</button>
<form method="POST" action="panel/mundo/CargarFicheros.php" enctype="multipart/form-data">
<div class="form-group">
<label class="btn btn-outline-secondary" for="my-file-selector">
<input required="" type="file" name="file" id="exampleInputFile">
<button class="btn btn-info" type="submit"><i class="fas fa-upload"></i> Cargar Fichero</button>
</label>
</div>
</form>
<table id="tablaRespaldos" class="table table-striped table-bordered" style="width:100%">
<thead>
<tr>
<th width="3%" scope="col">#</th>
<!--<th width="7%" scope="col">#</th>-->
<th scope="col">Nombre Archivo</th>
<th width="26%" scope="col">Acciones</th>
<!--<th width="10%" scope="col">Acciones</th>-->
</tr>
</thead>
<tbody id="respaldos">
<?php
$archivosSrv = scandir("servername");
$num = 0;
for ($i = 2; $i < count($archivosSrv); $i++) {
$num++;
?>
<p>
</p>
<tr>
<th scope="row"><?php echo $num; ?></th>
<td><?php echo $archivosSrv[$i]; ?></td>
<td>
<a href="servername/<?php echo $archivosSrv[$i]; ?>" download="<?php echo $archivosSrv[$i]; ?>" data-toggle="tooltip" data-placement="top" title="Descargar" type="submit" class="btn btn-info btn-sm" name="accion"><i class="fas fa-download"></i></a>
<form style="display: inline-block" method="POST" action="panel/propiedades/ver_archivo_srv.php">
<input type="hidden" name="log" value="<?php echo $archivosSrv[$i] ?>">
<input type="hidden" name="num" value="<?php echo $num ?>">
<button value="log" data-toggle="tooltip" data-placement="top" title="Ver Archivo # <?php echo $num; ?>" type="submit" class="btn btn-warning btn-sm" name="accion"><i class="fas fa-eye"></i></button>
</form>
<a href="panel/mundo/eliminar.php?name=../../servername/<?php echo $archivosSrv[$i]; ?>" value="Seleccionar" onclick="return Confirmar('Realmente desea eliminar <?php echo $archivosSrv[$i]; ?> del Servidor servername? :(');"data-toggle="tooltip" data-placement="top" title="Eliminar" type="submit" class="btn btn-danger btn-sm" name="accion"><i class="fas fa-trash-alt"></i></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<ul>
<?php listadoDirectorio('../minecraftbe'); ?>
</ul>
</div>
<?php include 'panel/includes/footer.php' ?>
<!-- php include '../includes/modal.php'?> -->
<!-- <script src="includes/ajax1.js"> </script> -->
<script src="panel/includes/js/logs.js"> </script>
</body>
</html>