我是 opencart 购物车的新手,我在测试服务器上成功安装了它,但是当我尝试登录管理面板时,登录大约需要 40 到 50 分钟。
我调试代码并了解到,在每次登录请求时,opencart 都会向 yahoo 服务器发送 curl 请求以获取货币值,以下方法演示相同。
public function updateCurrencies($force = false) {
if (extension_loaded('curl')) {
$data = array();
if ($force) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "'");
} else {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "currency WHERE code != '" . $this->db->escape($this->config->get('config_currency')) . "' AND date_modified < '" . $this->db->escape(date('Y-m-d H:i:s', strtotime('-1 day'))) . "'");
}
foreach ($query->rows as $result) {
$data[] = $this->config->get('config_currency') . $result['code'] . '=X';
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://download.finance.yahoo.com/d/quotes.csv?s=' . implode(',', $data) . '&f=sl1&e=.csv');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$content = curl_exec($curl);
curl_close($curl);
$lines = explode("\n", trim($content));
foreach ($lines as $line) {
$currency = utf8_substr($line, 4, 3);
$value = utf8_substr($line, 11, 6);
if ((float)$value) {
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '" . (float)$value . "', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($currency) . "'");
}
}
$this->db->query("UPDATE " . DB_PREFIX . "currency SET value = '1.00000', date_modified = '" . $this->db->escape(date('Y-m-d H:i:s')) . "' WHERE code = '" . $this->db->escape($this->config->get('config_currency')) . "'");
$this->cache->delete('currency');
}
}
我通过将 opencart 中的更新货币设置为“否”跳过了这一步,并解决了这个问题,现在只需一秒钟即可在后端登录。
我的问题是,真的有必要更新 opencart 中的货币吗?