bebeboutik-scripts/clean_image.php
2017-12-18 17:14:31 +01:00

49 lines
1.9 KiB
PHP
Executable File

<?php
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['SERVER_PORT'] = 80;
include dirname(__FILE__).'/www/config/config.inc.php';
$link = new Link();
$id_product = array();
foreach(Db::getInstance()->ExecuteS('
SELECT `id_product`
FROM `'._DB_PREFIX_.'product_ps_cache`
WHERE `id_sale` > 2500
AND `id_sale` < 3500
-- AND `id_product` < 100000
') as $row) {
$id_product[] = (int) $row['id_product'];
}
echo count($id_product)."\n\n";
foreach(Db::getInstance()->ExecuteS('
SELECT *
FROM `'._DB_PREFIX_.'image`
WHERE `id_product` IN ('.implode(', ', $id_product).')
-- AND `id_product` NOT IN (23606, 3522, 23607, 24483, 11752, 35837, 85644, 124519, 269752)
') as $row) {
$folder = Image::getImgFolderStatic((int) $row['id_image']);
unlink(dirname(__FILE__).'/www/img/p/'.$folder.(int) $row['id_image'].'-thickbox.jpg');
unlink(dirname(__FILE__).'/www/img/p/'.$folder.(int) $row['id_image'].'-small.jpg');
unlink(dirname(__FILE__).'/www/img/p/'.$folder.(int) $row['id_image'].'-medium.jpg');
unlink(dirname(__FILE__).'/www/img/p/'.$folder.(int) $row['id_image'].'-large.jpg');
unlink(dirname(__FILE__).'/www/img/p/'.$folder.(int) $row['id_image'].'-home.jpg');
// unlink(dirname(__FILE__).'/www/img/p/'.(int) $row['id_product'].'-'.(int) $row['id_image'].'-thickbox.jpg');
// unlink(dirname(__FILE__).'/www/img/p/'.(int) $row['id_product'].'-'.(int) $row['id_image'].'-small.jpg');
// unlink(dirname(__FILE__).'/www/img/p/'.(int) $row['id_product'].'-'.(int) $row['id_image'].'-medium.jpg');
// unlink(dirname(__FILE__).'/www/img/p/'.(int) $row['id_product'].'-'.(int) $row['id_image'].'-large.jpg');
// unlink(dirname(__FILE__).'/www/img/p/'.(int) $row['id_product'].'-'.(int) $row['id_image'].'-home.jpg');
if((int) $row['id_product'] % 200 == 0) {
echo $row['id_product']."\n";
}
}