private function addRepo() { if (!SPFactory::mainframe()->checkToken()) { Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::WARNING, 0, __LINE__, __FILE__); $this->response(Sobi::Url('extensions.browse'), SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), false, SPC::ERROR_MSG); exit; } $connection = SPFactory::Instance('services.remote'); $repo = trim(preg_replace('/[^a-zA-Z0-9\\.\\-\\_]/', null, SPRequest::string('repository'))); $ssl = $connection->certificate($repo); if (isset($ssl['err'])) { SPFactory::mainframe()->cleanBuffer()->customHeader(); //$response = sprintf( 'The connection could not be validated (error number %s). %s', $ssl[ 'err' ], $ssl[ 'msg' ] ); $response = SPLang::e('NOT_VALIDATED', $ssl['err'], $ssl['msg']); echo json_encode(array('message' => array('type' => SPC::ERROR_MSG, 'text' => $response))); exit; } else { $cert = array(); $file = SPFactory::Instance('base.fs.file', SPLoader::path('etc.repos.' . str_replace('.', '_', $repo), 'front', false, 'xml')); $cert['url'] = 'https://' . $repo; $cert['certificate']['serialNumber'] = $ssl['serialNumber']; $cert['certificate']['validFrom'] = Sobi::Date($ssl['validFrom_time_t']); $cert['certificate']['validTo'] = Sobi::Date($ssl['validTo_time_t']); $cert['certificate']['subject'] = $ssl['subject']; $cert['certificate']['issuer'] = $ssl['issuer']; $cert['certificate']['hash'] = $ssl['hash']; $def = SPFactory::Instance('types.array', $cert); $file->content($def->toXML($cert, 'repository')); $file->save(); /** @var $view SPExtensionsView */ $view =& SPFactory::View('extensions', true)->assign($this->_task, 'task')->assign($cert['certificate'], 'certificate')->determineTemplate('extensions', 'certificate'); ob_start(); $view->display(); $response = ob_get_contents(); $response = str_replace('id="SobiPro"', 'id="SpRepoModal"', $response); SPFactory::mainframe()->cleanBuffer()->customHeader(); echo json_encode(array('message' => array('type' => SPC::INFO_MSG, 'response' => $response))); exit; } }