<?php $_REQUEST['src']='ext'; require_once('global.php');

if($_REQUEST['FUNCTION']=="saveimage"){

function base64ToImage($imageData){
    $data = 'data:image/png;base64,AAAFBfj42Pj4';
    list($type, $imageData) = explode(';', $imageData);
    list(,$extension) = explode('/',$type);
    list(,$imageData)      = explode(',', $imageData);
    $fileName = $_REQUEST['invoiceCode'].'.'.$extension;
    $imageData = base64_decode($imageData);
    file_put_contents('../invoices/'.$fileName, $imageData);
}
base64ToImage($_REQUEST[image]);
}


function get_tiny_url($url)  {  
	$ch = curl_init();  
	$timeout = 5;  
	curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);  
	curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);  
	curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);  
	$data = curl_exec($ch);  
	curl_close($ch);  
	return $data;  
}
$thurl='https://'.getCompanyDetails('web').'/payments/paybounce.php?code='.$_REQUEST['code'].'&invoice='.$_REQUEST['invoice'].'&amount='.$_REQUEST['amount'];
$string=rawurlencode($thurl);
$url=get_tiny_url($string);
echo $url;
?>
