<?php
//function miximgs_upl($adtitl, $frm, $nam, $sz, $tm)
function miximgs_upl($nam, $sz, $tm) {
// escaper
//$adtitl = addslashes(mysql_real_escape_string($adtitl));
//$adtitl = base64_decode(base64_decode($adtitl));
//list($bfid, $brttl) = explode("____", $adtitl);
function brid()
{
$password_length = 22;
$alfa = "1234567890abcdefghijklmnopqrstuvwxyz";
$token = "";
for($i = 1; $i < $password_length; $i ++) {
  @$token .= $alfa[rand(1, strlen($alfa))];
}    
return $token;
}
// chk dupl 
//$chkdupbrandad = mysql_query("select _str_mgzs from cop_categ where _str_mgzs = '".$bfid."'");
//if(mysql_num_rows($chkdupbrandad) == 0) {
$path = "assets/shops/";
		//$nw_arng_infidk = mysql_real_escape_string(base64_decode(trim($_POST['lnd_frm_pstx'])));
		//header('Content-type: image/jpeg');  
			
			$name = $nam;
			$size = $sz;
			$valid_formats = array("jpg");
			if(strlen($name))
				{
					list($txt, $ext) = explode(".", $name);
					if(in_array($ext,$valid_formats))
					{
					if($size<(151*76))
						{
							$actual_image_name = md5(base64_encode($name)).".".$ext; // time().substr(str_replace(" ", "_", $txt), 5).".".$ext;
							$tmp = $tm;
							if(move_uploaded_file($tmp, $path.$actual_image_name))
								{
					
list($width, $height, $type, $attr) = getimagesize($path.$actual_image_name);						
//$newthumbname = $thumb_path.$actual_image_name;
//get the dimensions for the thumbnail
$thumb_width = $width * 0.10;
$thumb_height = $height * 0.10;
//create the thumbnail
$largeimage = imagecreatefromjpeg($path.$actual_image_name);
$thumb = imagecreatetruecolor(52, 62);
imagecopyresampled($thumb, $largeimage, 0, 0, 0, 0, 52, 62, $width, $height);

//imagejpeg($thumb, $newthumbname);
imagedestroy($largeimage);
imagedestroy($thumb);

///////////////////////////////////////////////////////////////
/*
$decod_dc_nmsdtls =  base64_decode($_POST['dc_dtlt']);
$get_dc_proprty = "select dc_pfidky from _dc_trgenrl where _dc_tnme = '".$decod_dc_nmsdtls."' limit 0,1";
$snd_dc_gtquery = mysql_query($get_dc_proprty);
$_dc_frn_id_proprty = mysql_fetch_row($snd_dc_gtquery);
*/

// temp healthtik ad with path
//$tmp_hlttik_ad_placr = "../rwm_ings/Web Ad/helthtik_own_ad.jpg";  , 

		/*
			$inst_mgdtl = "INSERT INTO _cbrnd_admstr (_adb_ndfidky, _bndad_uidki, _brnaad_nm, _admg_inm, _adbl_kplc, _adsz, _adu_pip) 
			VALUES ('".$bfid."', 'ba".brid()."', '".$frm."', '".$actual_image_name."', '".$brttl."', '".$size."', '".$_SERVER['REMOTE_ADDR']."')";
			$finiliz_qry = mysql_query($inst_mgdtl) or die(mysql_error()); //sSET profile_image='$actual_image_name' WHERE uid='$session_id'");
									echo "<br>";
									echo "<font color='#00EA00'>Ad For Brand Has Been Uploaded Successfully</font>";
									echo "<br>";
									echo "<br>";
									echo "<img src='_adb_ands/".$actual_image_name."'  class='preview'>";
									echo "<br>";
									
		*/								
							return $actual_image_name;
									
								}
							else
								echo "<div id='err_alert'>Failed</div>";
						}
						else
						echo "<div id='err_alert'>Image file size max 15 KB Allowed</div>";					
						}
						else
						echo "<div id='err_alert'>Invalid file format..</div>";	
				}
				
			else
				echo "<div id='err_alert'>Please select image..!</div>";
	//##############################################################################			
	//}else{
	//echo "This Brand's Ad Already Exist. Please Delete This First And Try Again";
	//} // nd dup chk f
	//##############################################################################			
			
} // nd multi upload function	



?>