public function index() { $this->language->load('common/update'); $data = $this->language->all(); $this->document->setTitle($data['heading_title']); if (!$this->validate('access')) { exit; } if (isset($this->session->data['msg_success'])) { $data['text_success'] = $this->session->data['msg_success']; unset($this->session->data['msg_success']); } if (isset($this->session->data['msg_error'])) { $data['text_error'] = $this->session->data['msg_error']; unset($this->session->data['msg_error']); } if (!extension_loaded('xml')) { $data['text_error'] = $this->language->get('error_xml'); } if (!extension_loaded('zip')) { $data['text_error'] = $this->language->get('error_zip'); } $data['token'] = $this->session->data['token']; $data['check'] = $this->url->link('common/update/check', 'token=' . $this->session->data['token'], 'SSL'); $data['update'] = $this->url->link('common/update/update', 'token=' . $this->session->data['token'], 'SSL'); $data['changelog'] = $this->url->link('common/update/changelog', 'token=' . $this->session->data['token'], 'SSL'); $addon = new Addon($this->registry); $data['addons'] = $addon->getAddons(); $data['updates'] = $this->update->getUpdates(); $data['header'] = $this->load->controller('common/header'); $data['column_left'] = $this->load->controller('common/column_left'); $data['footer'] = $this->load->controller('common/footer'); $this->response->setOutput($this->load->view('common/update.tpl', $data)); }
public function api() { $json = array(); $this->load->language('extension/marketplace'); $this->document->setTitle($this->language->get('heading_title')); if ($this->validate()) { if (isset($this->session->data['cookie']) && isset($this->request->get['api'])) { // Include any URL parameters $url_data = array(); foreach ($this->request->get as $key => $value) { if ($key != 'route' && $key != 'token' && $key != 'store_id' && $key != 'api') { $url_data[$key] = $value; } } if (isset($this->request->get['store']) and !empty($this->request->get['store'])) { $this->apiBaseUrl = str_replace(parse_url($this->apiBaseUrl, PHP_URL_HOST), $this->request->get['store'] . '.' . parse_url($this->apiBaseUrl, PHP_URL_HOST), $this->apiBaseUrl); } $addon_lib = new Addon($this->registry); $addons = $addon_lib->getAddons(); foreach ($addons as $addon) { $data[$addon['product_id']] = $addon['product_version']; } if (isset($data)) { $this->request->post['addons'] = $data; } $curl = curl_init(); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLINFO_HEADER_OUT, true); curl_setopt($curl, CURLOPT_USERAGENT, $this->request->server['HTTP_USER_AGENT']); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_FORBID_REUSE, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_URL, $this->apiBaseUrl . 'index.php?route=' . $this->request->get['api'] . ($url_data ? '&' . http_build_query($url_data) : '')); if ($this->request->post) { curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($this->request->post)); } curl_setopt($curl, CURLOPT_COOKIE, session_name() . '=' . $this->session->data['cookie'] . ';'); $json = curl_exec($curl); curl_close($curl); } } else { $response = array(); $response['error']['warning'] = $this->error; unset($this->error); $json = json_encode($response); } if (!empty($this->request->server['HTTP_X_REQUESTED_WITH'])) { $this->response->addHeader('Content-Type: application/json'); $this->response->setOutput($json); } else { $this->response->addHeader('Content-Type: text/plain'); $this->response->setOutput($json); } }