<?php
class buda_hexandeal_class{
	 public  $dbcon;
     public  $host="localhost";
     public  $dbname="aiderste_hexandeal";
     public  $user="aiderste_aiderstech";
     public  $pwd="Aid@2022_2023";


                                      //FUNCTION FOR DATABASE CONNECTION GOES HERE
 
function __construct(){
	
		   $this->dbcon = new PDO("mysql:dbname=$this->dbname;host=$this->host",$this->user,$this->pwd);
          
}
//////////////////////////////////////////////CHECK THE CONFIRMATION CODE////////////////
  //////////////

 

/////////////////////////////////CHECK IF THE VALIDATION CODE GOES////////////////
///////////////////////////////////////////////////////////////////////////
/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
function getThisDealBySearch($searchValue){
	try{
		$ownerH=$this->dbcon->prepare("select * from  item_info where  description  like ?  or category like ? or title like ?   or locationaddress  like ?");
		//$ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(array('%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%')); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}

}
 

function vitemname($itemname) {
	 
	
		if(preg_match("/^[\sA-Za-z0-9]+$/",$itemname)  && $itemname!=""){
			return 	$itemname;
		} 
		 else{
		 	return false;
		 }
}  


function eitemname($itemname) {
	 if($itemname=="")
	               {

	 	return $itemname="Item name required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z0-9]+$/",$itemname))
	              {
		 
        return $itemname= "Error in typing item name!";
		          }
	 else         {
		          	return;
		          }
	           }                           



                               ////////////////////////////////
	                                    //  ROUTE DETAIL
function vcperson($cperson) {
	 
	
		if(preg_match("/^[\sA-Za-z0-9]+$/",$cperson)  && $cperson!=""){
			return 	$cperson;
		} 
		 else{
		 	return false;
		 }
}  


function ecperson($cperson) {
	 if($cperson=="")
	               {

	 	return $cperson="Name required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$cperson))
	              {
		 
        return $cperson= "Name typed!";
		          }
	 else         {
		          	return;
		          }
	           }                           

                               ////////////////////////////////


                                      //DISTRICT VALIDATION

function vDistrict($district) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$district)  && $district!=""){
			return 	$district;
		} 
		 else{
		 	return false;
		 }
}  


function eDistrict($district) {
	 if($district=="")
	               {

	 	return $district="District required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$district))
	              {
		 
        return $district= "Invalid district name!";
		          }
	 else         {
		          	return;
		          }
	 

}




                                      //REGION VALIDATION

function vRegion($region) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$region)  && $region!=""){
			return 	$region;
		} 
		 else{
		 	return false;
		 }
}  


function eRegion($region) {
	 if($region=="")
	               {

	 	return $region="Region required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$region))
	              {
		 
        return $district= "Invalid region name!";
		          }
	 else         {
		          	return;
		          }
		      }
	 

	                                    //  ROUTE DETAIL
function vitemcategory($itemcategory) {
	 
	
		if(preg_match("/^[\sA-Za-z0-9]+$/",$itemcategory)  && $itemcategory!=""){
			return 	$itemcategory;
		} 
		 else{
		 	return false;
		 }
}  


function eitemcategory($itemcategory) {
	 if($itemcategory=="")
	               {

	 	return $itemcategory="Category required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z0-9]+$/",$itemcategory))
	              {
		 
        return $itemcategory= "Error in typing category!";
		          }
	 else         {
		          	return;
		          }
	           }      



                               ////////////////////////////////
	                                    //  ROUTE DIRECTION VIA POINT
	                                      ////////////////////////////////
	                                    //  ROUTE DIRECTION VIA POINT
function vcost($itemcost) {
	 
	
		if(preg_match("/^[0-9]+$/",$itemcost)  && $itemcost!=""){
			return 	$itemcost;
		} 
		 else{
		 	return false;
		 }
}  


function ecost($itemcost ) {
	 if($itemcost=="")
	               {

	 	return $itemcost="Capital value required!..";
	               }
	
	 else if(!preg_match("/^[0-9]+$/",$itemcost))
	              {
		 
        return $itemcost= "Cost typed with error! ";
		          }
	 else         {
		          	return;
		          }
	           }                           
                    

	           /////////////
	           ////////////////
function vitemcost($itemcost,$currency) {
	 
	
		if(preg_match("/^[0-9]+$/",$itemcost)  && $itemcost!="" && $currency!=""){
			return 	$itemcost;
		} 
		 else{
		 	return false;
		 }
}  


function eitemcost($itemcost,$currency) {
	 if($itemcost=="" || $currency=="")
	               {

	 	return $itemcost="Both capital value and currency are required!..";
	               }
	
	 else if(!preg_match("/^[0-9]+$/",$itemcost))
	              {
		 
        return $via= "Cost typed with error! ";
		          }
	 else         {
		          	return;
		          }
	           }                           
                               ////////////////////////////////
	                                    //  ROUTE DETAIL

//PHONE NUMBER VALIDATION

function vcphone($cphone) {
	 
	
		if(preg_match("/\d{10,12}/",$cphone)  && $cphone!=""){
			return 	$cphone;
		} 
		 else{
		 	return false;
		 }
}  


function ecphone($cphone) {
	 if($cphone=="")
	               {

	 	return $cphone="Phone number required!..";
	               }

   
	 else if(!preg_match("/\d{10,12}/",$cphone))
	              {
		 
        return $cphone= "Invalid phone number!..";
		          }
	 else         {
		          	return;
		          }
	 

}
function vitemdescription($itemdescription) {
	 
	
		if($itemdescription!=""){
			return 	$itemdescription;
		} 
		 else{
		 	return false;
		 }
}  


function eitemdescription($itemdescription) {
	 if($itemdescription=="")
	               {

	 	return $itemdescription="Description required!..";
	               }
	 
	 else         {
		          	return;
		          }
	           }                           


                               ///////////////////////////////
	           ///////
	                                    //  ROUTE DETAIL
function vlocationdescription($locationdescription) {
	 
	
		if($locationdescription!=""){
			return 	$locationdescription;
		} 
		 else{
		 	return false;
		 }
}  


function elocationdescription($locationdescription) {
	 if($locationdescription=="")
	               {

	 	return $locationdescription="Location description required!..";
	               }
	 
	 else         {
		          	return;
		          }
	           }                           


                               ///////////////////////////////

	           /////////////////MESSAGE VALIDATION/////////////////


	           function vmessage($message) {
	 
	
		if($message!=""){
			return 	$message;
		} 
		 else{
		 	return false;
		 }
}  


function emessage($message) {
	 if($message=="")
	               {

	 	return $message="message required!..";
	               }
	 
	 else         {
		          	return;
		          }
	           }                           
 
 
	           //////////////////ADD ROUTE FUNCTION GOES HERE
	           ///////////////////////


////////////////////////GET DEALS///////////////////////
 
function getOtherHexaNdeal($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from deal where advertiserid!=:Id");
	    $ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
////////
////////////////////////GET ///////////////////////   


////////////////////////GET DEALS///////////////////////
 
function getMyHexaNdealPost($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from deal where advertiserid=:Id");
	    $ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
////////
////////////////////////GET ///////////////////////
////////////////////////GET DEALS///////////////////////
 
function getHexaNdealPostOut(){
	try{
		$ownerH=$this->dbcon->prepare("select * from deal order by posteddate DESC");
	   // $ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
////////
////////////////////////GET ///////////////////////
////////////////////////GET DEALS///////////////////////
 
function getOtherNeedPost($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from need where adverstiserid!=:Id");
	    $ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
/////////////////
////////////////////////GET DEALS///////////////////////
 
function getMyNeedPostPeopleOffer($ownID,$needid){
	try{
		$ownerH=$this->dbcon->prepare("select * from needoffer where needid=:nid and receiverid=:cid");
	    $ownerH->bindParam(":nid",$needid);
	    $ownerH->bindParam(":cid",$ownID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
////////
////////////////////////GET ///////////////////////
////////
////////////////////////GET ///////////////////////
////////////////////////GET DEALS///////////////////////
 
function getNeedPostOut(){
	try{
		$ownerH=$this->dbcon->prepare("select * from need order by posteddate DESC");
	   // $ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
////////
////////////////////////GET /////////////////////// 
////////////////////////GET DEALS///////////////////////
 
function getMyNeedPost($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from need where adverstiserid=:Id");
	    $ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
////////
////////////////////////GET ///////////////////////                 

function updateDealPrice($dealid,$itemcost,$ownID){
	
       
	 $data=array($itemcost,$dealid,$advertiserid);
       try{
	
	    $Qr=$this->dbcon->prepare("update deal set cvalue=? where dealid=? and advertiserid=?");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

 
      catch(PDOException $ex){
	  $ex->getMessage();
}
} 
//////////////////////// UPDATE ENDS//////////////
////////////////////////

////////////////////////UPDATE STATUS ///////////////////////                 

function updateDealStatus($dealid,$ownID){
	
     $status="Expired";
	 $data=array($status,$dealid,$ownID);
       try{
	
	    $Qr=$this->dbcon->prepare("update deal set status=? where dealid=? and advertiserid=?");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

 
      catch(PDOException $ex){
	  $ex->getMessage();
}
} 
//////////////////////// UPDATE ENDS//////////////
//////////////////
///////////////////////                 

function upgradeDealStatus($dealid,$ownID){
	
     $status="Readvertised";

     $deadline=date("Y-m-d",strtotime("+7 day"));
	 $data=array($status,$deadline,$dealid,$ownID);
       try{
	
	    $Qr=$this->dbcon->prepare("update deal set status=?,addeadline=? where dealid=? and advertiserid=?");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

 
      catch(PDOException $ex){
	  $ex->getMessage();
}
} 
//////////////////////// UPDATE ENDS//////////////

///////////////////////////////////////// 
///////////////////////


function addDealPost($dealid,$itemdescription,$itemcost,$itemcategory,$itemname,$cphone,$cperson,$locationdescription,$ownID,$fn,$currency){
	
      
     $site="../hexaNimages/".$fn;
     $deadline=date("Y-m-d",strtotime("+7 day"));
     $status="Current";
	 $data=array($dealid,$itemdescription,$itemcost,$itemcategory,$itemname,$cphone,$cperson,$locationdescription,$ownID,$deadline,$site,$currency,$status);
       try{
	
	    $Qr=$this->dbcon->prepare("insert into deal(dealid,description,cvalue,category,title,cphone,cperson,locationaddress,advertiserid,addeadline,profileimage,currency,status) values(?,?,?,?,?,?,?,?,?,?,?,?,?)");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

 
      catch(PDOException $ex){
	  $ex->getMessage();
}
} 
//////////////////////// ITEM DETAIL VALIDATIO NEND//////////////
///////////////////////////////////////////////////////////////// 
///////////////////////

///////////////////////////////////////// 
///////////////////////


function addNeedPost($needid,$ownID,$itemname,$cperson,$cphone,$region,$district,$locationdescription,$itemcategory,$itemdescription){
	
       
     $deadline=date("Y-m-d",strtotime("+7 day"));
     $status="Current";
	 $data=array($needid,$ownID,$itemname,$cperson,$cphone,$region,$district,$locationdescription,$itemcategory,$itemdescription,$deadline,$status);
       try{
	
	    $Qr=$this->dbcon->prepare("insert into need(needid,adverstiserid,title,cperson,cphone,region,district,street,category,description,deadline,status) values(?,?,?,?,?,?,?,?,?,?,?,?)");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

 
      catch(PDOException $ex){
	  $ex->getMessage();
}
} 
//////////////////////// ITEM DETAIL VALIDATIO NEND//////////////
/////////////////////

/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function getOtherThisDealDetail($dealid,$ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from deal where dealid=:id and advertiserid!=:owid"); 
		$ownerH->bindParam(":id",$dealid);
		$ownerH->bindParam(":owid",$ownID);   
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}

}

/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function getOtherThisNeedDetail($needid,$posterid){
	try{
		$ownerH=$this->dbcon->prepare("select * from need where needid=:id and adverstiserid=:owid"); 
		$ownerH->bindParam(":id",$needid);
		$ownerH->bindParam(":owid",$posterid);   
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}

}


/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////


/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function getThisMyNeedDetail($ownID,$needid){
	try{
		$ownerH=$this->dbcon->prepare("select * from need where needid=:id and adverstiserid=:owid"); 
		$ownerH->bindParam(":id",$needid);
		$ownerH->bindParam(":owid",$ownID);   
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}

}


/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER////////
function getMyDealDetail($dealid,$ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from deal where dealid=:id and advertiserid=:owid"); 
		$ownerH->bindParam(":id",$dealid);
		$ownerH->bindParam(":owid",$ownID);   
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}

}




/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function getMyDealImage($dealid){
	try{
		$ownerH=$this->dbcon->prepare("select * from dealimage where dealid=:id"); 
		$ownerH->bindParam(":id",$dealid);    
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}

}
	//////////////////FUNCTION FOR RETRIEVING ENDS/////////////////
///////////////////////////UPDATE PROFILE IMAGES//////////////////////
/////////////////////////////////////////////////////////////////// 

function updateProfileImage($itemid,$shopid,$profile){
	 
	 $data=array($profile,$shopid,$itemid);
       try{
	
	      $Qr=$this->dbcon->prepare("update item_info set profileimages=? where shopid=? and itemid=?");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

 
      catch(PDOException $ex){
	  $ex->getMessage();
}
} 
////////////////////////////IMAGE TITLE//////////////////
///////////////////////UPDATE ITEM PROFILE/////////////////////
////////////////////////////////////////////////////////

function updateItem($itemid,$itemdescription,$itemcost,$itemcategory,$itemname,$itemtype,$expiredate,$shopid,$currency){
	 
	 $data=array($itemname,$itemtype,$itemcategory,$itemcost,$itemdescription,$expiredate,$currency,$shopid,$itemid);
       try{
	
	      $Qr=$this->dbcon->prepare("update item_info set itemname=?,itemtype=?,itemcategory=?,itemcost=?, description=?,expiredate=?, currency=? where shopid=? and itemid=?");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

 
      catch(PDOException $ex){
	  $ex->getMessage();
}
} 
////////////////////////////IMAGE TITLE//////////////////

function vimagename($itemname) {
	 
	
		if(preg_match("/^[\sA-Za-z0-9]+$/",$itemname)  && $itemname!=""){
			return 	$itemname;
		} 
		 else{
		 	return false;
		 }
}  


function eimagename($itemname) {
	 if($itemname=="")
	               {

	 	return $itemname="Image name required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z0-9]+$/",$itemname))
	              {
		 
        return $itemname= "Error in image name!";
		          }
	 else         {
		          	return;
		          }
	           }                           



////////////////////////////////////////////
//////////////////////////////////////////////   FUNCTION  FOR IMAGE VALIDATIO  GOES HERE //////////////////////
function vImageType($ext,$allowedtype) {
	 
	if(in_array($ext,$allowedtype))
	{
      
      return $ext;
		  
    }
	else
	 {
	  return false; 
	 }

     }  



function eImageType($ext,$allowedtype) {
	 
	if(in_array($ext,$allowedtype))
	{
      
      return;
		  
    }
	else
	 {
	  return $ex= "The extension ".$ext." is not type of an image!..";
	 }

     }  
                                      //TYPE OF IMAGE ENDS




                             //IMAGE SIZE VALIDATION

function vImageSize($size) {
	 
	if($size>=0 && $size<2000000)
	{
      
      return $size;
		  
    }
	else
	 {
	  return false; 
	 }

     }  



function eImageSize($size) 
 {
	 
	if($size>=0 && $size<2000000)
	{
      
      return;
		  
    }
	 else
    {
	 return $size= "The Height:  ".$height." and   Width: ".$width."   of image is not within range!..";
    }


} 
                                      //VALIDATION  OF IMAGE SIZE ENDS


                             //IMAGE ERROR VALIDATION

function vImageError($error) {
	 
	if($error <= 0)
	{
      
      return true;
		  
    }
	else
	 {
	  return false; 
	 }

     }  



function eImageError($error) 
 {
	 
	if($error > 0)
	{
      
      return $err="An error: ".$error." occurred while uploading file!..."; 

		  
    }
	 else
    {
	 return ;
    }


} 

//IMAGE ERROR VALIDATION

                            //CHECK IF IMAGE EXIST

function vImageExist($fn) {
	 
	if(file_exists("../hexaNimages/".$fn))
	{
      
      return false;
		  
    }
	else
	 {
	  return true; 
	 }

     }  



function eImageExist($fn) 
 {
	 
	
if(file_exists("../hexaNimages/".$fn))
	{
      
      return  $exs= "The ".$fn." already uploaded!..";
  
    }
	 else
    {
	 return ;
    }


} 


                            //CHECK IF IMAGE SELECTED

function vImageSelectF($fn) {
	 
	if($fn=="")
	{
      
      return false;
		  
    }
	else
	 {
	  return true; 
	 }

     }  



function eImageSelectF($fn) 
 {
	 
	
if($fn=="")
	{
      
      return  $exs= "Select file to upload!..";
  
    }
	 else
    {
	 return ;
    }


} 

/////////////////////////////////UPLOAD ITEM IMAGES/////////////////////

function uploadImage($fn,$itemname,$tmp_name,$dealid){
	

 

$site="../hexaNimages/".$fn;
 $ext = strtolower($site);

  $info = getimagesize($tmp_name);

  if ($info['mime'] == 'image/jpeg')
  {
      
    $image = imagecreatefromjpeg($tmp_name);
  }
  elseif ($info['mime'] == 'image/gif') 
  {
    $image = imagecreatefromgif($tmp_name);
  }
  elseif ($info['mime'] == 'image/png')
  { 
    $image = imagecreatefrompng($tmp_name);
  }
 //imagejpeg($image, $site, 1);
	 $data=array($site,$itemname,$dealid);
try{
	
	$Qr=$this->dbcon->prepare("insert into dealimage(directory,title,dealid ) values(?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
     imagejpeg($image, $site, 1);
     //move_uploaded_file($tmp_name,$site);

           
          return $Qr;//="The image is successfully uploaded!..";
	 }
	 else
	 {
	 	  return $Qr= $Qr->ErrorInfo(); //$Re="Oops your network is low to upload data!..";
	 } 

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
////////////////////////////////////////////// 
/////////////////////////////////UPLOAD ITEM IMAGES/////////////////////

function postNeedOffering0($itemdescription,$offerid,$needid,$senderid,$receiverid){
	

 

    //$site="../hexaNimages/".$fn;
	 
	 $data=array($itemdescription,$offerid,$needid,$senderid,$receiverid);
try{
	
	$Qr=$this->dbcon->prepare("insert into needoffer(description,offerid,needid,senderid,receiverid) values(?,?,?,?,?)");
	//I have lenovo ipad with good camera resolutionand it take clear photo..
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {

    // move_uploaded_file($tmp_name,$site);

           
          return $Qr;//="The image is successfully uploaded!..";
	 }
	 else
	 {
	 	  return $Qr= $Qr->ErrorInfo(); //$Re="Oops your network is low to upload data!..";
	 } 

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
//offerid 	needid 	senderid 	receiverid 	description 	directory 	poston 
////////////////////////////////////////////// 
/////////////////////////////////UPLOAD ITEM IMAGES/////////////////////

function postNeedOffering($offerid,$needid,$senderid,$receiverid,$itemdescription,$fn,$tmp_name){
	

 

    $site="../hexaNimages/".$fn;
     $ext = strtolower($site);

  $info = getimagesize($tmp_name);

  if ($info['mime'] == 'image/jpeg')
  {
      
    $image = imagecreatefromjpeg($tmp_name);
  }
  elseif ($info['mime'] == 'image/gif') 
  {
    $image = imagecreatefromgif($tmp_name);
  }
  elseif ($info['mime'] == 'image/png')
  { 
    $image = imagecreatefrompng($tmp_name);
  }
 //imagejpeg($image, $site, 1);
	 
	 $data=array($offerid,$needid,$senderid,$receiverid,$itemdescription,$site);
try{
	
	$Qr=$this->dbcon->prepare("insert into needoffer(offerid,needid,senderid,receiverid, 	description,directory) values(?,?,?,?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {

     //move_uploaded_file($tmp_name,$site);
           imagejpeg($image, $site, 1);
           
          return $Qr;//="The image is successfully uploaded!..";
	 }
	 else
	 {
	 	  return $Qr= $Qr->ErrorInfo(); //$Re="Oops your network is low to upload data!..";
	 } 

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
//offerid 	needid 	senderid 	receiverid 	description 	directory 	poston 
//////////////////////////////////////////////                                       //////////////////////
///////////////////////////////////////////////////// IMAGE VALIDATION ENDS  ///////////////////
}
?>
