
PK 
<?php
function get_cate_exists($cate, $parent_id, $typ=""){
$query="select * from cate where bname='$cate' and parent_id='$parent_id' and typ='$typ'";
$q=mysql_query($query) or die(mysql_error());
if(mysql_num_rows($q)>0)
return 1;
else
return 0;
}
/*function get_cate_exists($cate){
$query="select * from cate where bname='$cate'";
$q=mysql_query($query) or die(mysql_error());
if(mysql_num_rows($q)>0)
return 1;
else
return 0;
}*/
function getColumn($table, $field, $val, $col, $orderby=""){
if($orderby!=""){
$or=" order by ".$orderby;
}
$q="select $col from $table where $field='$val' $or";
$q=mysql_query($q) or die(mysql_error());
if($r=mysql_fetch_array($q)){
return $r[0];
}else{
return false;
}
}
function thumb_jpeg($sourceImage,$destinationImageName,$destinationPath,$newWidth,$newHeight) {
$srcNewImg=ImageCreateFromJPEG($sourceImage) or die("Problem In opening Source Image");
$x=ImageSX($srcNewImg);
$y=ImageSY($srcNewImg);
$mlt_w = $newWidth / $x;
$mlt_h = $newHeight / $y;
$mlt = $mlt_w < $mlt_h ? $mlt_w:$mlt_h;
#### Calculate new dimensions
$img_new_width = round($x * $mlt);
$img_new_height = round($y * $mlt);
$destinationImage=ImageCreateTrueColor($img_new_width,$img_new_height) or die("Problem In Creating image");
ImageCopyResized($destinationImage,$srcNewImg,0,0,0,0,$img_new_width,$img_new_height,ImageSX($srcNewImg),ImageSY($srcNewImg)) or die("Problem In resizing");
if(ImageJPEG($destinationImage,"$destinationPath/$destinationImageName",100)){
ImageDestroy($destinationImage);
return true;
} else {
return false;
}
}
function createthumb($srcimg){
// Set a few variables
$image = "uploads/" . $srcimg;
$newimage = "uploads/th_" . $srcimg;
$image_quality = 80;
$addborder = 0;
$max_height = 115;
$max_width = 115;
// Main code
$src_img = ImageCreateFromJpeg($image);
$orig_x = ImageSX($src_img);
$orig_y = ImageSY($src_img);
$new_y = $max_height;
$new_x = $orig_x/($orig_y/$max_height);
if ($new_x > $max_width) {
$new_x = $max_width;
$new_y = $orig_y/($orig_x/$max_width);
}
$dst_img = ImageCreateTrueColor($new_x,$new_y);
ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $new_x, $new_y, $orig_x, $orig_y);
if ($addborder == 1){
// Add border
$black = ImageColorAllocate($dst_img, 0, 0, 0);
ImageSetThickness($dst_img, 1);
ImageLine($dst_img, 0, 0, $new_x, 0, $black);
ImageLine($dst_img, 0, 0, 0, $new_y, $black);
ImageLine($dst_img, $new_x-1, 0, $new_x-1, $new_y, $black);
ImageLine($dst_img, 0, $new_y-1, $new_x, $new_y-1, $black);
}
ImageJpeg($dst_img, $newimage, $image_quality);
ImageDestroy($src_img);
ImageDestroy($dst_img);
}
function createthumb1($srcimg){
// Set a few variables
$image = "../products/" . $srcimg;
$newimage = "../products/th_" . $srcimg;
$image_quality = 100;
$addborder = 0;
$max_width = 270;
$max_height = 350;
// Main code
$src_img = ImageCreateFromJpeg($image);
$orig_x = ImageSX($src_img);
$orig_y = ImageSY($src_img);
$new_y = $max_height;
$new_x = $orig_x/($orig_y/$max_height);
if ($new_x > $max_width) {
$new_x = $max_width;
$new_y = $orig_y/($orig_x/$max_width);
}
$dst_img = ImageCreateTrueColor($new_x,$new_y);
ImageCopyResampled($dst_img, $src_img, 0, 0, 0, 0, $new_x, $new_y, $orig_x, $orig_y);
if ($addborder == 1){
// Add border
$black = ImageColorAllocate($dst_img, 0, 0, 0);
ImageSetThickness($dst_img, 1);
ImageLine($dst_img, 0, 0, $new_x, 0, $black);
ImageLine($dst_img, 0, 0, 0, $new_y, $black);
ImageLine($dst_img, $new_x-1, 0, $new_x-1, $new_y, $black);
ImageLine($dst_img, 0, $new_y-1, $new_x, $new_y-1, $black);
}
ImageJpeg($dst_img, $newimage, $image_quality);
ImageDestroy($src_img);
ImageDestroy($dst_img);
}
?>


PK 99