<?php
/*
+--------------------------------------------------------------------------
|   CubeCart v3.0.15
|   ========================================
|   by Alistair Brookbanks
|	CubeCart is a Trade Mark of Devellion Limited
|   Copyright Devellion Limited 2005 - 2006. All rights reserved.
|   Devellion Limited,
|   22 Thomas Heskin Court,
|   Station Road,
|   Bishops Stortford,
|   HERTFORDSHIRE.
|   CM23 3EE
|   UNITED KINGDOM
|   http://www.devellion.com
|	UK Private Limited Company No. 5323904
|   ========================================
|   Web: http://www.cubecart.com
|   Date: Thursday, 4th January 2007
|   Email: sales (at) cubecart (dot) com
|	License Type: CubeCart is NOT Open Source Software and Limitations Apply 
|   Licence Info: http://www.cubecart.com/v4-software-license
+--------------------------------------------------------------------------
|	call.inc.php
|   ========================================
|	APC for the Nochex Gateway	
+--------------------------------------------------------------------------
*/
if (!defined('CC_INI_SET')) die("Access Denied");
## Read the POST data and compile request string for validation call
$params = array();
foreach ($_POST as $key => $value){
	$value		= urlencode(stripslashes($value));
	$params[]	= "$key=$value";
}
$params			= implode('&', $params);
$validation_url	= "www.nochex.com";

## Post back to Nochex server to validate
$header .= "POST /nochex.dll/apc/apc HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".strlen($params)."\r\n\r\n";
$fp = fsockopen($validation_url, 80, $errno, $errstr, 30);

if (!$fp) {
	## HTTP ERROR
} else {
	fputs($fp, $header.$params);
	while (!feof($fp)) {
		$res = fgets($fp, 1024);
		if (strcmp($res, 'AUTHORISED') == 0) {
			$order->orderStatus(3, $_POST['order_id']);
			break;
		}
	}
	fclose($fp);
}
?>