refs #404 removes innecesaries functions
parent
65fbd4f319
commit
2bf53c1ec6
|
|
@ -3,54 +3,9 @@
|
||||||
|
|
||||||
namespace App\OgBootBundle\Service;
|
namespace App\OgBootBundle\Service;
|
||||||
use Exception;
|
use Exception;
|
||||||
include_once (__DIR__ . '/../../../etc/php-vars.php');
|
|
||||||
$conf_file = parse_ini_file(__DIR__ . '/../../../etc/ogAdmServer.cfg');
|
|
||||||
define('OG_REST_API_TOKEN', 'Authorization: ' . $conf_file['APITOKEN']);
|
|
||||||
|
|
||||||
class CurlRequestService
|
class CurlRequestService
|
||||||
{
|
{
|
||||||
function common_request($command, $type, $data = null) {
|
|
||||||
|
|
||||||
$json = json_encode($data);
|
|
||||||
|
|
||||||
$service_url = OG_REST_URL.$command;
|
|
||||||
|
|
||||||
$curl = curl_init($service_url);
|
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
|
||||||
OG_REST_API_TOKEN,
|
|
||||||
));
|
|
||||||
echo __DIR__ . '/../../../etc/ssl/WebConsole.crt.pem';
|
|
||||||
curl_setopt ($curl, CURLOPT_SSLCERT, __DIR__ . '/../../../etc/ssl/WebConsole.crt.pem');
|
|
||||||
curl_setopt ($curl, CURLOPT_SSLKEY, __DIR__ . '/../../../etc/ssl/WebConsole.key.pem');
|
|
||||||
if (curl_error($curl)) {
|
|
||||||
echo 'Error setting key: ' . curl_error($curl);
|
|
||||||
}
|
|
||||||
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
|
|
||||||
switch ($type) {
|
|
||||||
default:
|
|
||||||
case GET:
|
|
||||||
break;
|
|
||||||
case POST:
|
|
||||||
curl_setopt($curl, CURLOPT_POST, true);
|
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
|
|
||||||
}
|
|
||||||
|
|
||||||
$curl_response = curl_exec($curl);
|
|
||||||
$info = curl_getinfo($curl);
|
|
||||||
var_dump($info);
|
|
||||||
|
|
||||||
if ($curl_response === false || $info['http_code'] != 200) {
|
|
||||||
syslog(LOG_ERR, 'error occured during curl exec. Additioanl info: ' . print_r($info, TRUE));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
curl_close($curl);
|
|
||||||
|
|
||||||
syslog(LOG_INFO, 'response '.$command.' ok!');
|
|
||||||
|
|
||||||
return json_decode($curl_response, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function convertMaskToCIDR($mask)
|
public function convertMaskToCIDR($mask)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue