function myq($query) { $result = @mysql_query($query); if (!$result) { //echo "$query <br /><br />"; die(mysql_error()); } else { $row = mysql_fetch_full_result_array($result); } return $row; }
function make_files_with_watermark($id) { $imagedir = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/images/"; $product_images = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/product_images/"; $filedir = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/files/"; $export_dir = "/home/www/cb3/wp-content/plugins/wp-shopping-cart/slides/"; $wm = "/home/www/cb3/img/watermark.png"; $chwidth = $chheight = 600; //$fileid_data = $wpdb->get_results("SELECT `file` FROM `wp_product_list` WHERE `id` = '$id' LIMIT 1",ARRAY_A); $sql = "SELECT `file` FROM `wp_product_list` WHERE `id` = '{$id}' LIMIT 1"; $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error()); } $fileid_data = mysql_fetch_full_result_array($result); $fileid = $fileid_data[0]['file']; //$file_data = $wpdb->get_results("SELECT * FROM `wp_product_files` WHERE `id` = '$fileid' LIMIT 1",ARRAY_A); $sql = "SELECT * FROM `wp_product_files` WHERE `id` = '{$fileid}' LIMIT 1"; $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error()); } $file_data = mysql_fetch_full_result_array($result); $idhash = $file_data[0]['idhash']; if (file_exists($filedir . $idhash)) { $mimetype = $file_data[0]['mimetype']; $filename = $file_data[0]['filename']; $height = 600; $width = 600; //$imagedir = $basepath."/wp-content/plugins/wp-shopping-cart/images/"; //$product_images = $basepath."/wp-content/plugins/wp-shopping-cart/product_images/"; //$filedir = $basepath."/wp-content/plugins/wp-shopping-cart/files/"; copy($filedir . $idhash, $imagedir . $filename); // icon copy($filedir . $idhash, $product_images . $filename); // preview $imgsize = getimagesize($product_images . $filename); $file_w = $imgsize[0]; $file_h = $imgsize[1]; //ales here we replace slides to that from LG $chwidth = 600; // crop size $chheight = 600; // crop size //$thatdir = $product_images; //destination dir $ifolder = ''; //subfolder for artist $file = $filename; // $resample_quality = 100; //image quality // slide al_create_resized_file($chwidth, $chheight, $product_images, $ifolder, $file, $resample_quality); // watremark $wm = $basepath . "/img/watermark.png"; wtrmark($product_images . $file, $wm); // icon al_create_cropped_file(140, 140, $imagedir, $ifolder, $file, $resample_quality); } else { echo "<div class='error'><b>WARNING:</b> original file is not found at: " . $filedir . $idhash . " <br /></div>"; } }
$wm = ROOTDIR . "img/watermark.png"; $chwidth = $chheight = 600; // get the list of files // connect to db $con = mysql_connect("localhost", "z58365_cbru3", "greenbat"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("z58365_cbru3", $con); $sql = "SELECT *, f.filename, f.idhash, f.mimetype FROM `wp_product_files` as f,`wp_product_list` as l WHERE l.active='1' and f.id=l.file ORDER BY l.id ASC"; $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error()); } $counter = 1; $img_array = mysql_fetch_full_result_array($result); mysql_close($con); $i = 0; foreach ($img_array as $row) { if ($i < 3300) { echo "\n\ncount: " . $i; $idhashname = $row['idhash']; $slidename = $row['filename']; $mimetype = $row['mimetype']; $id = $row['id']; $file_ext = substr($mimetype, 6, strlen($mimetype)); // get the file $file_path = $filedir . $idhashname . '.' . $file_ext; $idhash_path = $filedir . $idhashname; if (file_exists($idhash_path)) { echo " \n Resizing. slidename: " . $slidename . " idhashname: " . $idhashname;