37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
include 'config.php';
|
|
include 'constants.php';
|
|
|
|
function external_internal_call($in, &$out) {
|
|
global $target_url; // = svrlayer/internal.php";
|
|
$fields_string = "";
|
|
//url-ify the data for the POST
|
|
foreach ($in as $key => $value) {
|
|
$fields_string .= $key . '=' . $value . '&';
|
|
}
|
|
rtrim($fields_string, '&');
|
|
//open connection
|
|
$ch = curl_init();
|
|
//set the url, number of POST vars, POST data
|
|
curl_setopt($ch, CURLOPT_URL, $target_url);
|
|
curl_setopt($ch, CURLOPT_POST, count($in));
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
|
//execute post
|
|
$result = curl_exec($ch);
|
|
//close connection
|
|
curl_close($ch);
|
|
|
|
// Parse result
|
|
foreach (explode("\n", $result) as $line) {
|
|
if ($line == "" || strpos($line, "=") === false)
|
|
continue;
|
|
$key = trim(strtok($line, "="));
|
|
if ($key != "") {
|
|
$out[$key] = base64_decode(substr($line, 1 + strlen($key)));
|
|
}
|
|
}
|
|
}
|