PK

ADDRLIN : /home/anibklip/msbhogalnsons.com/cms/
FLL :
Current File : /home/anibklip/msbhogalnsons.com/cms/functions.php

<?php
function SetMenuActiveClass($ar){
	if(in_array($_GET[paction],$ar)){
		return "active open";
	}
}

function getColumn($table, $field, $val, $col, $orderby=""){
	if($orderby!=""){
		$or=" order by ".$orderby;
	}
	$q="select $col from $table where $field='$val' $or";
	$q=mysqli_query($GLOBALS['conn'],$q) or die(mysqli_error($GLOBALS['conn']));
	if($r=mysqli_fetch_array($q)){
		return $r[0];
	}else{
		return false;
	}
}
function imagecreatefromjpeg_new($path_img) {
	$Oldsize = @getimagesize($path_img);
	$mime = $Oldsize['mime'];
	
	if ($mime == 'image/jpeg' or $mime == 'image/pjpeg') $OldImg=imagecreatefromjpeg($path_img);
	elseif ($mime == 'image/gif') $OldImg=imagecreatefromgif($path_img);
	elseif ($mime == 'image/png') $OldImg=imagecreatefrompng($path_img);
	else return(false);
	return($OldImg);
}

function createthumb($srcimg,$fname,$upload_dir,$max_width=800,$max_height=600){
	// Set a few variables 
	$image = $srcimg; 
	$newimage = "$upload_dir/" . $fname; 
	$image_quality = 100; 
	$addborder = 0; 
	/*$max_height = 800; 
	$max_width = 600; */
	// Main code 
	
	//$src_img = ImageCreateFromJpeg($image); 
	$src_img = imagecreatefromjpeg_new($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