-
Notifications
You must be signed in to change notification settings - Fork 6
/
cron.php
68 lines (56 loc) · 1.84 KB
/
cron.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
<?php
include 'config.php';
$sth = mysqli_query($link,"SELECT logo FROM `asada`");
$array = array();
while($r = mysqli_fetch_assoc($sth)) {
if ($r['logo'] != ''){
$porciones = explode("/", $r['logo']);
array_push($array,$porciones[2]);
}
}
$sth = mysqli_query($link,"SELECT imagen FROM `noticia`");
while($r = mysqli_fetch_assoc($sth)) {
if ($r['imagen'] != ''){
$porciones = explode("/", $r['imagen']);
array_push($array,$porciones[2]);
}
}
$sth = mysqli_query($link,"SELECT plantilla FROM `tramite`");
while($r = mysqli_fetch_assoc($sth)) {
if ($r['plantilla'] != ''){
$porciones = explode("/", $r['plantilla']);
array_push($array,$porciones[2]);
}
}
$sth = mysqli_query($link,"SELECT respuesta FROM `formulario`");
while($r = mysqli_fetch_assoc($sth)) {
$array1 = json_decode($r['respuesta'],true);
foreach($array1 as $valor){
$porciones = explode("/", $valor);
if ($porciones[0] == "uploads"){
array_push($array,$porciones[2]);
}
}
}
function listar_directorios_ruta($ruta,$array){
if (is_dir($ruta)){
if ($dh = opendir($ruta)){
if ($ruta != 'uploads/ordenes/'){
//echo "$ruta <br>";
while (($file = readdir($dh)) !== false){
if ($file!="." && $file!=".."){
//echo "<br />$file";
if (!in_array($file, $array)) {
//echo "NO EXISTE $ruta$file <BR>";
unlink($ruta.$file);
}
listar_directorios_ruta($ruta . $file . DIRECTORY_SEPARATOR,$array);
}
}
}
closedir($dh);
}
}
}
listar_directorios_ruta('uploads/',$array);
?>