- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
$db = new DB_Sql();
$db->connect();
$sql = "SELECT distinct(absnum) FROM articles";
$db->query($sql);
while ($db->next_record()){
$is_img_sql[] = $db->f('absnum');
}
$Open = opendir($_SERVER['DOCUMENT_ROOT'].'/img/forall/a/');
while(false !== ($gdir = readdir($Open))){
if($gdir != "." && $gdir != ".."){
$dir[] = $gdir;
}
}
closedir($Open);
foreach ($dir as $fdir){
if(is_dir($_SERVER['DOCUMENT_ROOT'].'/img/forall/a/'.$fdir.'/')){
$Open2 = opendir($_SERVER['DOCUMENT_ROOT'].'/img/forall/a/'.$fdir.'/');
while(false !== ($gdir2 = readdir($Open2))){
if($gdir2 != "." && $gdir2 != ".."){
$tmp = intval($fdir.ereg_replace("\..*","",$gdir2));
if(!in_array($tmp,$is_img_sql)){
$delfile = $_SERVER['DOCUMENT_ROOT'].'/img/forall/a/'.$fdir.'/'.$gdir2;
if (is_file($delfile)){
if (unlink($delfile)){
echo "Файл <b>".$delfile."</b> удален<br>";
}
}
}
}
}
closedir($Open2);
}
}
$Open = opendir($_SERVER['DOCUMENT_ROOT'].'/img/g/');
while(false !== ($gdirg = readdir($Open))){
if($gdirg != "." && $gdirg != ".."){
$dirg[] = $gdirg;
}
}
closedir($Open);
foreach ($dirg as $fdir){
$Open2 = opendir($_SERVER['DOCUMENT_ROOT'].'/img/g/'.$fdir.'/');
while(false !== ($gdir2 = readdir($Open2))){
if($gdir2 != "." && $gdir2 != ".."){
$tmp = intval($fdir.$gdir2.ereg_replace("\..*","",$gdir3));
if(!in_array($tmp,$is_img_sql)){
$delfile = $_SERVER['DOCUMENT_ROOT'].'/img/g/'.$fdir.'/'.$gdir2;
if (is_dir($delfile)){
$Opendel = opendir($delfile);
while(false !== ($gdirdel = readdir($Opendel))){
if($gdirdel != "." && $gdirdel != ".."){
$tpmdel = $delfile."/".$gdirdel;
if (is_file($tpmdel)){
unlink($tpmdel);
}
}
}
if (rmdir($delfile)){
echo "Директория <b>".$delfile."</b> удалена<br>";
}
}
}
}
}
closedir($Open2);
}
$sql = "SELECT distinct(absnum) FROM price";
$db->query($sql);
while ($db->next_record()){
$is_img_price[] = $db->f('absnum');
}
$Open = opendir($_SERVER['DOCUMENT_ROOT'].'/img/forall/p/');
while(false !== ($gdirp = readdir($Open))){
if($gdirp != "." && $gdirp != ".."){
$dirp[] = $gdirp;
}
}
closedir($Open);
foreach ($dirp as $fdir){
$Open2 = opendir($_SERVER['DOCUMENT_ROOT'].'/img/forall/p/'.$fdir.'/');
while(false !== ($gdir2 = readdir($Open2))){
if($gdir2 != "." && $gdir2 != ".."){
$tmp = intval($fdir.ereg_replace("\..*","",$gdir2));
if(!in_array($tmp,$is_img_price)){
$delfile = $_SERVER['DOCUMENT_ROOT'].'/img/forall/p/'.$fdir.'/'.$gdir2;
if (is_file($delfile)){
if (unlink($delfile)){
echo "Файл <b>".$delfile."</b> удален<br>";
}
}
}
}
}
__proto__ 01.02.2014 23:39 # 0
jfhs 25.08.2021 04:33 # 0