rendered paste body<?php
ini_set("memory_limit","128M");
ini_set("include_path", ".:/usr/local/php/fooglue/libs:../src:../wwwroot:../conf");
$current_image_path = "../wwwroot/images/covers/";
$new_image_path = "../wwwroot/newimages/covers/";
include_once "com/dragonflymc/smartmart/data/ProductDAO.php";
include_once "org/fooglue/kernel/DataAccessObject.php";
include_once "org/fooglue/database/MySQLUtils.php";
$GLOBALS["CONFIG_FILE"] = "wwwroot-config.ini";
$conn = DataAccessObject::getConnection();
$sql = "select p.product_id
from tbl_product p
where is_disabled = 0";
$products = selectColumn($conn, $sql);
$productDAO = new ProductDAO();
DataAccessObject::close();
$numprods = count($products);
$counter = 0;
foreach($products as $product) {
$counter++;
echo "processing product id " . $product . " number ${counter} of ${numprods}\n";
$prodDetails = $productDAO->selectProductDetails($product);
$isbn10 = $prodDetails->getIsbn10();
$giffile = $isbn10 . ".gif";
$jpgfile = $isbn10 . ".jpg";
$newjpg = $isbn10 . ".jpg";
$smallnewjpg = $isbn10 . "_small.jpg";
$folder = $new_image_path . substr($isbn10, 0, 3) . "";
$c_folder = $current_image_path . substr($isbn10, 0, 2) ."";
if (!is_dir($folder)) {
mkdir($folder);
}
if (file_exists($c_folder . "/" . $giffile)) {
$old = $c_folder . "/" . $giffile;
$new = $folder . $newjpg;
$small = $folder . $smallnewjpg;
$command = exec("/usr/bin/convert {$old} {$new}");
$command = exec("/usr/bin/convert -scale x100 {$old} {$small}");
}
else if(file_exists($c_folder . "/" . $jpgfile)) {
$old = $c_folder . "/" . $giffile;
$new = $folder . $newjpg;
$small = $folder . $smallnewjpg;
$command = exec("/usr/bin/convert {$old} {$new}");
$command = exec("/usr/bin/convert -scale x100 {$old} {$small}");
}
}
?>