-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean.php
128 lines (127 loc) · 4.3 KB
/
clean.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
<?php
require_once('config.inc.php');
$dirs=glob('*');
$dirs=array_filter($dirs, 'is_dir');
$dirs=array_diff($dirs,array('__others'));
foreach($dirs as $dir)
{
if(SAVEHTM) {
$files=glob($dir.'/*.htm');
$chs=array();
foreach($files as $file)
{
if(filesize($file)==0) { unlink($file); continue; }
$ch=explode('/',$file);
$ch=$ch[1];
$ch=explode('.',$ch);
$ch=$ch[0];
$ch=explode('-',$ch);
$ch=array_map('trim',$ch);
if(array_key_exists($ch[0],$chs)) {
var_dump($dir,$chs[$ch[0]],$ch);
echo '<br/>';
if(count($ch)==1 && $chs[$ch[0]]>$ch[0]) unlink($dir.'/'.$ch[0].'.htm');
else if($chs[$ch[0]] > $ch[1]) unlink($dir.'/'.$ch[0].' - '.$ch[1].'.htm');
else if($chs[$ch[0]] < $ch[1]) unlink($dir.'/'.$ch[0].' - '.$chs[$ch[0]].'.htm');
if(SAVEGZ) {
if(count($ch)==1 && $chs[$ch[0]]>$ch[0]) unlink($dir.'/'.$ch[0].'.htm.gz');
else if($chs[$ch[0]] > $ch[1]) unlink($dir.'/'.$ch[0].' - '.$ch[1].'.htm.gz');
else if($chs[$ch[0]] < $ch[1]) unlink($dir.'/'.$ch[0].' - '.$chs[$ch[0]].'.htm.gz');
}
}
if(count($ch)==1) $chs[$ch[0]]=$ch[0];
else $chs[$ch[0]]=$ch[1];
}
}
if(SAVEGZ) {
$files=glob($dir.'/*.htm.gz');
$chs=array();
foreach($files as $file)
{
if(filesize($file)==0 || filesize($file)==18) { unlink($file); continue; }
$ch=explode('/',$file);
$ch=$ch[1];
$ch=explode('.',$ch);
$ch=$ch[0];
$ch=explode('-',$ch);
$ch=array_map('trim',$ch);
if(array_key_exists($ch[0],$chs)) {
var_dump($dir,$chs[$ch[0]],$ch);
echo '<br/>';
if(SAVEHTM) {
if(count($ch)==1 && $chs[$ch[0]]>$ch[0]) unlink($dir.'/'.$ch[0].'.htm');
else if($chs[$ch[0]] > $ch[1]) unlink($dir.'/'.$ch[0].' - '.$ch[1].'.htm');
else if($chs[$ch[0]] < $ch[1]) unlink($dir.'/'.$ch[0].' - '.$chs[$ch[0]].'.htm');
}
if(count($ch)==1 && $chs[$ch[0]]>$ch[0]) unlink($dir.'/'.$ch[0].'.htm.gz');
else if($chs[$ch[0]] > $ch[1]) unlink($dir.'/'.$ch[0].' - '.$ch[1].'.htm.gz');
else if($chs[$ch[0]] < $ch[1]) unlink($dir.'/'.$ch[0].' - '.$chs[$ch[0]].'.htm.gz');
}
if(count($ch)==1) $chs[$ch[0]]=$ch[0];
else $chs[$ch[0]]=$ch[1];
}
}
}
$dirs2=glob('__others/*');
$dirs2=array_filter($dirs2, 'is_dir');
foreach($dirs2 as $dir)
{
if(SAVEHTM) {
$files=glob($dir.'/*.htm');
$chs=array();
foreach($files as $file)
{
if(filesize($file)==0) { unlink($file); continue; }
$ch=explode('/',$file);
$ch=$ch[2];
$ch=explode('.',$ch);
$ch=$ch[0];
$ch=explode('-',$ch);
$ch=array_map('trim',$ch);
if(array_key_exists($ch[0],$chs)) {
var_dump($dir,$chs[$ch[0]],$ch);
echo '<br/>';
if(count($ch)==1 && $chs[$ch[0]]>$ch[0]) unlink($dir.'/'.$ch[0].'.htm');
else if($chs[$ch[0]] > $ch[1]) unlink($dir.'/'.$ch[0].' - '.$ch[1].'.htm');
else if($chs[$ch[0]] < $ch[1]) unlink($dir.'/'.$ch[0].' - '.$chs[$ch[0]].'.htm');
if(SAVEGZ) {
if(count($ch)==1 && $chs[$ch[0]]>$ch[0]) unlink($dir.'/'.$ch[0].'.htm.gz');
else if($chs[$ch[0]] > $ch[1]) unlink($dir.'/'.$ch[0].' - '.$ch[1].'.htm.gz');
else if($chs[$ch[0]] < $ch[1]) unlink($dir.'/'.$ch[0].' - '.$chs[$ch[0]].'.htm.gz');
}
}
if(count($ch)==1) $chs[$ch[0]]=$ch[0];
else $chs[$ch[0]]=$ch[1];
}
}
if(SAVEGZ) {
$files=glob($dir.'/*.htm.gz');
$chs=array();
foreach($files as $file)
{
if(filesize($file)==0 || filesize($file)==18) { unlink($file); continue; }
$ch=explode('/',$file);
$ch=$ch[2];
$ch=explode('.',$ch);
$ch=$ch[0];
$ch=explode('-',$ch);
$ch=array_map('trim',$ch);
if(array_key_exists($ch[0],$chs)) {
var_dump($dir,$chs[$ch[0]],$ch);
echo '<br/>';
if(SAVEHTM) {
if(count($ch)==1 && $chs[$ch[0]]>$ch[0]) unlink($dir.'/'.$ch[0].'.htm');
else if($chs[$ch[0]] > $ch[1]) unlink($dir.'/'.$ch[0].' - '.$ch[1].'.htm');
else if($chs[$ch[0]] < $ch[1]) unlink($dir.'/'.$ch[0].' - '.$chs[$ch[0]].'.htm');
}
if(count($ch)==1 && $chs[$ch[0]]>$ch[0]) unlink($dir.'/'.$ch[0].'.htm.gz');
else if($chs[$ch[0]] > $ch[1]) unlink($dir.'/'.$ch[0].' - '.$ch[1].'.htm.gz');
else if($chs[$ch[0]] < $ch[1]) unlink($dir.'/'.$ch[0].' - '.$chs[$ch[0]].'.htm.gz');
}
if(count($ch)==1) $chs[$ch[0]]=$ch[0];
else $chs[$ch[0]]=$ch[1];
}
}
}
echo '<br/>'.date('Y-m-d H:i:s');
?>