public static function addonsRequest($request, $params = array()) { if (!self::$is_addons_up) { return false; } $postData = http_build_query(array('version' => isset($params['version']) ? $params['version'] : _PS_VERSION_, 'iso_lang' => Tools::strtolower(isset($params['iso_lang']) ? $params['iso_lang'] : Context::getContext()->language->iso_code), 'iso_code' => Tools::strtolower(isset($params['iso_country']) ? $params['iso_country'] : Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))), 'shop_url' => isset($params['shop_url']) ? $params['shop_url'] : Tools::getShopDomain(), 'mail' => isset($params['email']) ? $params['email'] : Configuration::get('PS_SHOP_EMAIL'))); $protocols = array('https'); switch ($request) { case 'native': $protocols[] = 'http'; $postData .= '&method=listing&action=native'; break; case 'native_all': $protocols[] = 'http'; $postData .= '&method=listing&action=native&iso_code=all'; break; case 'must-have': $protocols[] = 'http'; $postData .= '&method=listing&action=must-have'; break; case 'must-have-themes': $protocols[] = 'http'; $postData .= '&method=listing&action=must-have-themes'; break; case 'customer': $postData .= '&method=listing&action=customer&username='******'&password='******'customer_themes': $postData .= '&method=listing&action=customer-themes&username='******'&password='******'check_customer': $postData .= '&method=check_customer&username='******'username_addons']) . '&password='******'password_addons']); break; case 'check_module': $postData .= '&method=check&module_name=' . urlencode($params['module_name']) . '&module_key=' . urlencode($params['module_key']); break; case 'module': $postData .= '&method=module&id_module=' . urlencode($params['id_module']); if (isset($params['username_addons']) && isset($params['password_addons'])) { $postData .= '&username='******'username_addons']) . '&password='******'password_addons']); } else { $protocols[] = 'http'; } break; case 'install-modules': $protocols[] = 'http'; $postData .= '&method=listing&action=install-modules'; break; default: return false; } $context = stream_context_create(array('http' => array('method' => 'POST', 'content' => $postData, 'header' => 'Content-type: application/x-www-form-urlencoded', 'timeout' => 5))); foreach ($protocols as $protocol) { if ($content = Tools::file_get_contents($protocol . '://api.addons.prestashop.com', false, $context)) { return $content; } } self::$is_addons_up = false; return false; }