70 lines
1.6 KiB
PHP
70 lines
1.6 KiB
PHP
|
<?php
|
||
|
ini_set('display_errors', 0);
|
||
|
$_SERVER['SERVER_NAME'] = 'tk-ligat.ru';
|
||
|
|
||
|
|
||
|
require_once('/home/cloud/core/set/tk-ligat.ru.php');
|
||
|
|
||
|
//print_r($db);
|
||
|
|
||
|
require_once('/home/cloud/core/api/php/db.php');
|
||
|
require_once('/home/cloud/core/api/php/json.php');
|
||
|
|
||
|
function list_file ( $dir )
|
||
|
{
|
||
|
if ( $dir [ strlen( $dir ) - 1 ] != '/' ){
|
||
|
$dir .= '/';
|
||
|
}
|
||
|
$nDir = opendir( $dir );
|
||
|
while ( false !== ( $file = readdir( $nDir ) ) )
|
||
|
{
|
||
|
if ( $file != "." AND $file != ".." ){
|
||
|
if ( !is_dir( $dir . $file ) ){
|
||
|
$files [] = $file;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
closedir( $nDir );
|
||
|
return $files;
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
$imgList=list_file("/home/cloud/core/img/tk-ligat.ru/tovar");
|
||
|
|
||
|
for ($i=0; $i<count($imgList); $i++){
|
||
|
unset($id);
|
||
|
$fn= substr($imgList[$i], 0, 30);
|
||
|
|
||
|
|
||
|
$id=DB::getValue("SELECT `id` FROM `tovar_img` WHERE `filename`=?", $fn);
|
||
|
if (!$id ) {echo "Удалить\n";
|
||
|
unlink("/home/cloud/core/img/tk-ligat.ru/tovar/" . $imgList[$i]);
|
||
|
$r++;
|
||
|
}
|
||
|
else { echo "------------------ Оставить\n";
|
||
|
//sleep(5);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//print_r($imgList);
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
echo "\n\n\n Удалено $r файлов";
|
||
|
|
||
|
|
||
|
unset($imgList);
|
||
|
$imgList=DB::getAll("SELECT * FROM `tovar_img`");
|
||
|
for ($i=0; $i<count($imgList); $i++){
|
||
|
|
||
|
if (file_exists("/home/cloud/core/img/tk-ligat.ru/tovar/" . $imgList[$i]['filename'] . ".jpg")){
|
||
|
echo "есть\n";
|
||
|
}else{
|
||
|
echo "нету\n";
|
||
|
DB::set("DELETE FROM `tovar_img` WHERE `id`=?", $imgList[$i]['id']);
|
||
|
}
|
||
|
}
|
||
|
?>
|