Skip to content

Commit 50f72f0

Browse files
Create nochexapccurl.php
1 parent ae98294 commit 50f72f0

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

Curl/nochexapccurl.php

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
// Get the POST information from Nochex server
4+
$postvars = http_build_query($_POST);
5+
ini_set("SMTP","mail.nochex.com" );
6+
$header = "From: [email protected]";
7+
8+
// Set parameters for the email
9+
10+
$url = "https://www.nochex.com/apcnet/apc.aspx";
11+
12+
// Curl code to post variables back
13+
$ch = curl_init(); // Initialise the curl tranfer
14+
curl_setopt($ch, CURLOPT_URL, $url);
15+
curl_setopt($ch, CURLOPT_VERBOSE, true);
16+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
17+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
18+
curl_setopt($ch, CURLOPT_POST, true);
19+
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars); // Set POST fields
20+
curl_setopt($ch, CURLOPT_HTTPHEADER, "Host: www.nochex.com");
21+
curl_setopt($ch, CURLOPT_POSTFIELDSIZE, 0);
22+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
23+
curl_setopt($ch, CURLOPT_TIMEOUT, 60); // set connection time out variable - 60 seconds
24+
//curl_setopt ($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); // set openSSL version variable to CURL_SSLVERSION_TLSv1
25+
$output = curl_exec($ch); // Post back
26+
curl_close($ch);
27+
28+
// Put the variables in a printable format for the email
29+
$debug = "IP -> " . $_SERVER['REMOTE_ADDR'] ."\r\n\r\nPOST DATA:\r\n";
30+
foreach($_POST as $Index => $Value)
31+
$debug .= "$Index -> $Value\r\n";
32+
$debug .= "\r\nRESPONSE:\r\n$output";
33+
34+
//If statement
35+
if (!strstr($output, "AUTHORISED")) { // searches response to see if AUTHORISED is present if it isn’t a failure message is displayed
36+
$msg = "APC was not AUTHORISED.\r\n\r\n$debug"; // displays debug message
37+
}
38+
else {
39+
$msg = "APC was AUTHORISED.\r\n\r\n$debug"; // if AUTHORISED was found in the response then it was successful
40+
// whatever else you want to do
41+
}
42+
43+
//Email the response
44+
mail($to, 'APC - After If statement', $msg, $header);
45+
?>

0 commit comments

Comments
 (0)