getProducts(); //echo "
";var_dump($products);echo "";die(); $productsImages = Db::getInstance()->ExecuteS(' SELECT `id_image`, `id_product` FROM `'._DB_PREFIX_.'image` WHERE `id_product` IN ('.implode(',',$products).') ORDER BY `id_image` ASC'); $dir = _PS_PROD_IMG_DIR_; $type = ImageType::getImagesTypes('products'); /*$type = array(); $type[] = array('name' => 'thickbox'); $type[] = array('name' => 'small'); $type[] = array('name' => 'medium'); $type[] = array('name' => 'large'); $type[] = array('name' => 'home');*/ //echo "
";var_dump($productsImages,$type);echo "";die(); $start_time = time(); $max_execution_time = 7200; foreach ($productsImages AS $k => $image) { // delete old rezise image if (!is_dir($dir)) { continue; } $toDel = scandir($dir); foreach ($toDel AS $d) { foreach ($type AS $imageType) { if (preg_match('/^[0-9]+\-[0-9]+\-'.$imageType['name'].'\.jpg$/', $d) OR preg_match('/^([[:lower:]]{2})\-default\-(.*)\.jpg$/', $d)) { if (file_exists($dir.$d)) { unlink($dir.$d); } } } } $imageObj = new Image($image['id_image']); $imageObj->id_product = $image['id_product']; if (file_exists($dir.$imageObj->getImgFolder())) { $toDel = scandir($dir.$imageObj->getImgFolder()); foreach ($toDel AS $d) { foreach ($type AS $imageType) { if (preg_match('/^[0-9]+\-'.$imageType['name'].'\.jpg$/', $d)) { if (file_exists($dir.$imageObj->getImgFolder().$d)) { unlink($dir.$imageObj->getImgFolder().$d); } } } } } // regenerate new if (file_exists($dir.$imageObj->getExistingImgPath().'.jpg')) { foreach ($type AS $k => $imageType) { if (!file_exists($dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg')) { if (!imageResize($dir.$imageObj->getExistingImgPath().'.jpg', $dir.$imageObj->getExistingImgPath().'-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height']))) $errors = true; } if (time() - $start_time > $max_execution_time - 4) { // stop 4 seconds before the tiemout, just enough time to process the end of the page on a slow server return 'timeout'; } } } if((int) $image['id_product'] % 100 == 0) { echo $image['id_product']."\n"; } }