<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL && ~E_NOTICE);
include_once './db_functions.php'; 
$db = new DB_Functions(); 

$json = $_REQUEST["ImageUpload"];

function filesize_dir($file) {
        exec('dir ' . $file, $inf);
        $size_raw = $inf[6];
        $size_exp = explode(" ",$size_raw);
        $size_ext = $size_exp[19];
        $size_int = (float) str_replace(chr(255), '', $size_ext);
        return $size_int;
    }

if (get_magic_quotes_gpc()){ 
		$json = stripslashes($json); 
	}

//Decode JSON into an Array 
$data = json_decode($json);



$temp=0;
$a=array();



for($i=0; $i<count($data) ; $i++) {
	$id=$data[$i]->id;
    $b=array();


	$b["id"] = $id;          
	$b["status"] = 'yes'; 
	$temp++; // get  no of jobs for which images are uploaded 
    $ownerSignEncodedStr=$data[$i]->ownerSignEncodedStr;

    $ownerSignfileName = $data[$i]->ownerSignfileName;

    $binary1=base64_decode($ownerSignEncodedStr);
	$ownerSign = file_put_contents("kiosk_image/".$ownerSignfileName,$binary1);
////////////////////////////////////////////////////

  $salesPersonSignfileName=$data[$i]->salesPersonSignfileName;
 
     $salesPersonSignEncodedStr = $data[$i]->salesPersonSignEncodedStr;
 
     $binary2=base64_decode($salesPersonSignEncodedStr);
   $salesPersonSign = file_put_contents("kiosk_image/".$salesPersonSignfileName,$binary2);
 
///////////////////////////////////////////////////////////////
  
$kioskPersonfileName=$data[$i]->kioskPersonfileName;
 
$kioskPersonEncodedStr = $data[$i]->kioskPersonEncodedStr;

$binary3=base64_decode($kioskPersonEncodedStr);
$kioskPerson = file_put_contents("kiosk_image/".$kioskPersonfileName,$binary3);
/////////////////////////////////////////////////////

 
$shopfileName=$data[$i]->shopfileName;
 
$shopEncodedStr = $data[$i]->shopEncodedStr;

$binary4=base64_decode($shopEncodedStr);
$shopName = file_put_contents("kiosk_image/".$shopfileName,$binary4);


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


	
/*	
if($shopName=== FALSE) 
  die("Error writing data into $shopfileName");
else
  echo "$shopName bytes written to $shopfileName";
*/	

array_push($a,$b); 
}
  
 echo json_encode($a); 

?>
