Allow SyncTool with empty $server

pull/439/head
Richard van den Berg 2015-03-19 13:01:29 +01:00
parent 05bc4c4389
commit 106b6cb06b
2 changed files with 4 additions and 4 deletions

View File

@ -403,7 +403,7 @@ class ServersController extends AppController {
if(!empty($proxy['host'])) {
App::uses('SyncTool', 'Tools');
$syncTool = new SyncTool();
$HttpSocket = $syncTool->setupHttpSocket('www.example.com');
$HttpSocket = $syncTool->setupHttpSocket();
$proxyResponse = $HttpSocket->get('http://www.example.com/');
if(empty($proxyResponse)) {
$proxyStatus = 1;
@ -475,7 +475,7 @@ class ServersController extends AppController {
set_error_handler(function() {});
App::uses('SyncTool', 'Tools');
$syncTool = new SyncTool();
$HttpSocket = $syncTool->setupHttpSocket('api.github.com');
$HttpSocket = $syncTool->setupHttpSocket();
$response = $HttpSocket->get('https://api.github.com/repos/MISP/MISP/tags');
$tags = $response->body;
restore_error_handler();

View File

@ -2,10 +2,10 @@
class SyncTool {
// take a server as parameter and return a HttpSocket object using the ssl options defined in the server settings
public function setupHttpSocket($server) {
public function setupHttpSocket($server = null) {
$params = array();
App::uses('HttpSocket', 'Network/Http');
if(!empty($server['Server'])) {
if(!empty($server)) {
if ($server['Server']['cert_file']) $params['ssl_cafile'] = APP . "files" . DS . "certs" . DS . $server['Server']['id'] . '.pem';
if ($server['Server']['self_signed']) $params['ssl_allow_self_signed'] = $server['Server']['self_signed'];
}