-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtareas.php
254 lines (216 loc) · 14 KB
/
tareas.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
<?php
/*
This file is part of McWebPanel.
Copyright (C) 2020-2025 DEV-MCWEBPANEL
McWebPanel is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
McWebPanel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with McWebPanel. If not, see <https://www.gnu.org/licenses/>.
*/
require_once "template/session.php";
require_once "template/errorreport.php";
require_once "config/confopciones.php";
require_once "template/header.php";
?>
<!-- Custom styles for this template-->
<?php
if (isset($_SESSION['CONFIGUSER']['psystemconftemaweb'])) {
if ($_SESSION['CONFIGUSER']['psystemconftemaweb'] == 2) {
echo '<link href="css/dark.css" rel="stylesheet">';
echo '<link href="css/consoladark.css" rel="stylesheet">';
} else {
echo '<link href="css/light.css" rel="stylesheet">';
echo '<link href="css/consola.css" rel="stylesheet">';
}
} else {
echo '<link href="css/light.css" rel="stylesheet">';
echo '<link href="css/consola.css" rel="stylesheet">';
}
?>
</head>
<body id="page-top">
<?php
$expulsar = 0;
//COMPROBAR SI SESSION EXISTE SINO CREARLA CON NO
if (!isset($_SESSION['VALIDADO']) || !isset($_SESSION['KEYSECRETA'])) {
$_SESSION['VALIDADO'] = "NO";
$_SESSION['KEYSECRETA'] = "0";
header("location:index.php");
exit;
}
//COMPROBAR SI ES EL SUPERADMIN O ADMIN O USER CON PERMISOS
if ($_SESSION['CONFIGUSER']['rango'] == 1 || $_SESSION['CONFIGUSER']['rango'] == 2 || array_key_exists('pprogtareas', $_SESSION['CONFIGUSER']) && $_SESSION['CONFIGUSER']['pprogtareas'] == 1) {
$expulsar = 1;
}
if ($expulsar != 1) {
header("location:index.php");
exit;
}
//VALIDAMOS SESSION SINO ERROR
if ($_SESSION['VALIDADO'] == $_SESSION['KEYSECRETA']) {
function devolver_accion($laaccion)
{
if ($laaccion == "acc1") {
return "Apagar Servidor";
} elseif ($laaccion == "acc2") {
return "Iniciar Servidor";
} elseif ($laaccion == "acc3") {
return "Backup Servidor";
} elseif ($laaccion == "acc4") {
return "Enviar Comando";
}
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<!-- Page Wrapper -->
<div id="wrapper">
<!-- Sidebar -->
<?php
require_once "template/menu.php";
?>
<!-- End of Sidebar -->
<!-- Content Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">
<!-- Main Content -->
<div id="content">
<!-- Begin Page Content -->
<div class="container-fluid">
<div class="col-md-12">
<div class="card border-left-primary shadow h-100">
<div class="card-body">
<!-- Page Heading -->
<div class="py-1">
<div class="container">
<h1 class="">Programar Tareas</h1>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-striped table-borderless">
<thead>
<tr>
<th scope="col">Nombre</th>
<th scope="col">Acción</th>
<th scope="col">Comando</th>
<th scope="col">Estado</th>
<th scope="col">Acciones</th>
</tr>
</thead>
<tbody>
<?php
//INICIAR VARIABLES
$contadorarchivos = 0;
$eltamano = "";
$archivoconcreto = "";
//OBTENER RUTA BACKUPS
$rutaarchivo = getcwd();
$rutaarchivo = trim($rutaarchivo);
$rutaarchivo .= "/config";
$elarchivo = $rutaarchivo . "/array.json";
if (file_exists($elarchivo)) {
$contadorarchivos = 1;
}
//SI NO HAY ARCHIVOS MOSTRAR INFORMACION
if ($contadorarchivos == 0) {
echo ('<tr>');
echo ('<th scope="row">No hay ninguna tarea programada.</th><td></td><td></td><td></td><td></td>');
echo ('</tr>');
} else {
//OBTENER ARRAY TAREAS
$getarray = file_get_contents($elarchivo);
$arrayobtenido = unserialize($getarray);
//RECORRER ARRAY Y AÑADIR LAS PROPIEDADES Y LOS BOTONES
for ($i = 0; $i < count($arrayobtenido); $i++) {
echo ('<tr class="menu-hover" id="' . $arrayobtenido[$i]["id"] . '">');
echo ('<th scope="row">' . $arrayobtenido[$i]["nombre"] . '</th>');
echo ('<td>' . devolver_accion($arrayobtenido[$i]["accion"]) . '</td>');
echo ('<td>' . $arrayobtenido[$i]["comando"] . '</td>');
echo ('<td>' . $arrayobtenido[$i]["estado"] . '</td>');
echo ('<td>');
if ($_SESSION['CONFIGUSER']['rango'] == 1 || $_SESSION['CONFIGUSER']['rango'] == 2 || array_key_exists('pprogtareaseditar', $_SESSION['CONFIGUSER']) && $_SESSION['CONFIGUSER']['pprogtareaseditar'] == 1) {
?>
<button type="button" class="editartarea btn btn-primary text-white mr-1" value="<?php echo $arrayobtenido[$i]["id"]; ?>">Editar</button>
<?php
}
if ($_SESSION['CONFIGUSER']['rango'] == 1 || $_SESSION['CONFIGUSER']['rango'] == 2 || array_key_exists('pprogtareasactdes', $_SESSION['CONFIGUSER']) && $_SESSION['CONFIGUSER']['pprogtareasactdes'] == 1) {
?>
<button type="button" class="actdes btn btn-info text-white mr-1" value="<?php echo $arrayobtenido[$i]["id"]; ?>">Activar/Desactivar</button>
<?php
}
if ($_SESSION['CONFIGUSER']['rango'] == 1 || $_SESSION['CONFIGUSER']['rango'] == 2 || array_key_exists('pprogtareasborrar', $_SESSION['CONFIGUSER']) && $_SESSION['CONFIGUSER']['pprogtareasborrar'] == 1) {
?>
<button type="button" class="borrar btn text-white btn-danger" value="<?php echo $arrayobtenido[$i]["id"]; ?>">Borrar</button>
<?php
}
?>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
<hr>
<?php
if ($_SESSION['CONFIGUSER']['rango'] == 1 || $_SESSION['CONFIGUSER']['rango'] == 2 || array_key_exists('pprogtareascrear', $_SESSION['CONFIGUSER']) && $_SESSION['CONFIGUSER']['pprogtareascrear'] == 1) {
?>
<h1 class="">Crear Tarea</h1>
<div class="row">
<div class="col-md-4">
<button type="button" class="btn btn-primary btn-block btn-lg text-white mt-2" id="anadirtarea">Añadir Nueva Tarea</button>
</div>
<div class="col-md-8">
<p class="lead" id="textotarearetorno"></p>
</div>
</div>
<?php
}
?>
<hr>
<?php
if ($_SESSION['CONFIGUSER']['rango'] == 1 || $_SESSION['CONFIGUSER']['rango'] == 2 || array_key_exists('pprogtareaslog', $_SESSION['CONFIGUSER']) && $_SESSION['CONFIGUSER']['pprogtareaslog'] == 1) {
?>
<div class="row">
<div class="col-md-2">
<h1 class="">Log</h1>
</div>
<div class="col-md-10">
<button type="button" class="btn btn-primary text-white float-right" id="borrarlog">Borrar Archivo Log</button>
</div>
<textarea readonly="" class="form-control textoconsola mb-1" id="logcron" name="logcron" rows="18"></textarea>
</div>
<hr>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="js/tareas.js"></script>
<?php
//FINAL VALIDAR SESSION
} else {
header("location:index.php");
}
?>
</body>
</html>