Skip to content
Permalink
Browse files

[*] CORE: Removed hardcoded API urls

  • Loading branch information...
guestisp committed Jan 22, 2015
1 parent 2928bec commit cab6d52a189e69f137acae3122b3e3a29251ac06
@@ -402,7 +402,7 @@ public static function getDefaultCurrency()
public static function refreshCurrencies()
{
// Parse
if (!$feed = Tools::simplexml_load_file('http://api.prestashop.com/xml/currencies.xml'))
if (!$feed = Tools::simplexml_load_file(_PS_CURRENCY_FEED_URL_))
return Tools::displayError('Cannot parse feed.');
// Default feed currency (EUR)
@@ -459,4 +459,4 @@ public static function isMultiCurrencyActivated($id_shop = null)
{
return (Currency::countActiveCurrencies($id_shop) > 1);
}
}
}
@@ -46,8 +46,6 @@ class TabCore extends ObjectModel
/** @var integer hide_host_mode */
public $hide_host_mode = false;
const TAB_MODULE_LIST_URL = 'api.prestashop.com/xml/tab_modules_list.xml';
/**
* @see ObjectModel::$definition
*/
@@ -3316,6 +3316,17 @@ public static function purifyHTML($html)
return $html;
}
/**
* Check if a constant was already defined, if not, set a new constant with a value
*
* @param string $constant Constant name
* @param mixed $value Default value to set if not defined
*/
public static function safeDefine($constant, $value) {
if ( !defined($constant) )
define($constant, $value);
}
}
/**
@@ -27,8 +27,8 @@
class UpgraderCore
{
const DEFAULT_CHECK_VERSION_DELAY_HOURS = 24;
public $rss_version_link = 'http://api.prestashop.com/xml/upgrader.xml';
public $rss_md5file_link_dir = 'http://api.prestashop.com/xml/md5/';
public $rss_version_link;
public $rss_md5file_link_dir;
/**
* @var boolean contains true if last version is not installed
*/
@@ -52,6 +52,9 @@ class UpgraderCore
public function __construct($autoload = false)
{
$this->rss_version_link = _PS_API_URL_.'/xml/upgrader.xml';
$this->rss_md5file_link_dir = _PS_API_URL_.'/xml/md5/';
if ($autoload)
{
$this->loadFromConfig();
@@ -1889,7 +1889,7 @@ protected function initTabModuleList()
if (!$this->isFresh(Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, 86400))
@file_put_contents(_PS_ROOT_DIR_.Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have'));
if (!$this->isFresh(Module::CACHE_FILE_TAB_MODULES_LIST, 604800))
$this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, 'http://'.Tab::TAB_MODULE_LIST_URL);
$this->refresh(Module::CACHE_FILE_TAB_MODULES_LIST, _PS_TAB_MODULE_LIST_URL_);
$this->tab_modules_list = Tab::getTabModulesList($this->id);
@@ -81,3 +81,14 @@
define('_THEME_PROD_PIC_DIR_', __PS_BASE_URI__.'upload/');
define('_MAIL_DIR_', __PS_BASE_URI__.'mails/');
define('_MODULE_DIR_', __PS_BASE_URI__.'modules/');
/* Define API URLs if not defined by customer */
Tools::safeDefine('_PS_API_DOMAIN_', 'api.prestashop.com');
Tools::safeDefine('_PS_API_URL_', 'http://'._PS_API_DOMAIN_);
Tools::safeDefine('_PS_API_SSL_URL_', 'https://'._PS_API_DOMAIN_);
Tools::safeDefine('_PS_TAB_MODULE_LIST_URL_', 'http://'._PS_API_DOMAIN_.'/xml/tab_modules_list.xml');
Tools::safeDefine('_PS_API_MODULES_LIST_16_', _PS_API_DOMAIN_.'/xml/modules_list_16.xml');
// Different name for currency url. customers could customize just this without affecting all other apis
Tools::safeDefine('_PS_CURRENCY_FEED_URL_', 'http://'._PS_API_DOMAIN_.'/xml/currencies.xml');
@@ -227,7 +227,7 @@ public function renderView()
//'translations' => $translations,
'action' => '#',
'warning' => $this->getWarningDomainName(),
'new_version_url' => Tools::getCurrentUrlProtocolPrefix().'api.prestashop.com/version/check_version.php?v='._PS_VERSION_.'&lang='.$this->context->language->iso_code.'&autoupgrade='.(int)(Module::isInstalled('autoupgrade') && Module::isEnabled('autoupgrade')).'&hosted_mode='.(int)defined('_PS_HOST_MODE_'),
'new_version_url' => Tools::getCurrentUrlProtocolPrefix()._PS_API_DOMAIN_.'/version/check_version.php?v='._PS_VERSION_.'&lang='.$this->context->language->iso_code.'&autoupgrade='.(int)(Module::isInstalled('autoupgrade') && Module::isEnabled('autoupgrade')).'&hosted_mode='.(int)defined('_PS_HOST_MODE_'),
'dashboard_use_push' => Configuration::get('PS_DASHBOARD_USE_PUSH'),
'calendar' => $calendar_helper->generate(),
'PS_DASHBOARD_SIMULATION' => Configuration::get('PS_DASHBOARD_SIMULATION'),
@@ -343,7 +343,7 @@ public function ajaxProcessGetBlogRss()
{
$return = array('has_errors' => false, 'rss' => array());
if (!$this->isFresh('/config/xml/blog-'.$this->context->language->iso_code.'.xml', 86400))
if (!$this->refresh('/config/xml/blog-'.$this->context->language->iso_code.'.xml', 'https://api.prestashop.com/rss/blog/blog-'.$this->context->language->iso_code.'.xml'))
if (!$this->refresh('/config/xml/blog-'.$this->context->language->iso_code.'.xml', _PS_API_SSL_URL_.'/rss/blog/blog-'.$this->context->language->iso_code.'.xml'))
$return['has_errors'] = true;
if (!$return['has_errors'])
@@ -162,7 +162,7 @@ public function getTestResult()
public function displayAjaxCheckFiles()
{
$this->file_list = array('missing' => array(), 'updated' => array());
$xml = @simplexml_load_file('http://api.prestashop.com/xml/md5/'._PS_VERSION_.'.xml');
$xml = @simplexml_load_file(_PS_API_URL_.'/xml/md5/'._PS_VERSION_.'.xml');
if (!$xml)
die(Tools::jsonEncode($this->file_list));
@@ -194,4 +194,4 @@ public function getListOfUpdatedFiles(SimpleXMLElement $dir, $path = '')
foreach ($dir->dir as $subdir)
$this->getListOfUpdatedFiles($subdir, $path.$subdir['name'].'/');
}
}
}
@@ -176,7 +176,7 @@ public function postProcess()
if (($iso_localization_pack = Tools::getValue('iso_localization_pack')) && Validate::isFileName($iso_localization_pack))
{
if (Tools::getValue('download_updated_pack') == '1' || defined('_PS_HOST_MODE_'))
$pack = @Tools::file_get_contents('http://api.prestashop.com/localization/'.$version.'/'.$iso_localization_pack.'.xml');
$pack = @Tools::file_get_contents(_PS_API_URL_.'/localization/'.$version.'/'.$iso_localization_pack.'.xml');
else
$pack = false;
@@ -223,7 +223,7 @@ public function renderForm()
$localizations_pack = false;
$this->tpl_option_vars['options_content'] = $this->renderOptions();
$xml_localization = Tools::simplexml_load_file('http://api.prestashop.com/rss/localization.xml');
$xml_localization = Tools::simplexml_load_file(_PS_API_URL_.'/rss/localization.xml');
if (!$xml_localization)
{
$localization_file = _PS_ROOT_DIR_.'/localization/localization.xml';
@@ -245,7 +245,7 @@ public function renderForm()
}
if (!$localizations_pack)
return $this->displayWarning($this->l('Cannot connect to prestashop.com'));
return $this->displayWarning($this->l('Cannot connect to '._PS_API_URL_));
// Add local localization .xml files to the list if they are not already there
foreach (scandir(_PS_ROOT_DIR_.'/localization/') as $entry)
@@ -59,7 +59,7 @@ class AdminModulesControllerCore extends AdminController
protected $iso_default_country;
protected $filter_configuration = array();
protected $xml_modules_list = 'api.prestashop.com/xml/modules_list_16.xml';
protected $xml_modules_list = _PS_API_MODULES_LIST_16_;
/**
@@ -1982,7 +1982,7 @@ protected function _checkConfigForFeatures($arrFeatures, $configItem = array())
*/
private function getNativeModule($type = 0)
{
$xml = simplexml_load_string(Tools::file_get_contents('http://api.prestashop.com/xml/modules_list_16.xml'));
$xml = simplexml_load_string(Tools::file_get_contents(_PS_API_URL_.'/xml/modules_list_16.xml'));
if ($xml)
{

0 comments on commit cab6d52

Please sign in to comment.
You can’t perform that action at this time.