public function updateRates()
 {
     $model = new Model($this->config, $this->database);
     $exchange_rates = $model->getModel('\\modules\\exchange_rates\\classes\\models\\ExchangeRate');
     $exchange_rates->updateRates();
     $data = ['rates' => $exchange_rates->getAllRates()];
     $template = $this->getTemplate('pages/administrator/updated_rates.php', $data, 'modules/exchange_rates');
     $this->response->setContent($template->render());
 }
 public function before_request()
 {
     // Do not change if an admin is logged in
     if ($this->request->getAuthentication()->administratorLoggedIn()) {
         return;
     }
     $module_config = $this->config->moduleConfig('\\modules\\location_detect');
     $country = NULL;
     $model = new Model($this->config, $this->database);
     if ($this->request->requestParam('set_country')) {
         $country = $model->getModel('\\core\\classes\\models\\Country')->get(['code' => $this->request->requestParam('set_country')]);
         if ($country) {
             $this->request->session->set('site_country', $country->code);
             $this->logger->info("Setting Locale from Request: " . $country->code);
         }
     } elseif ($this->request->session->get('site_country')) {
         $country = $model->getModel('\\core\\classes\\models\\Country')->get(['code' => $this->request->session->get('site_country')]);
     } else {
         $remote_ip = $this->request->serverParam('REMOTE_ADDR');
         $country = $model->getModel('\\modules\\location_detect\\classes\\models\\CountryIP4')->findCountry($remote_ip);
         if ($country) {
             $this->logger->info("Setting Locale from IP: {$remote_ip} => " . $country->code);
         }
     }
     // Is the country valid
     if ($country && $module_config->allowed_countries) {
         if (!in_array($country->code, $module_config->allowed_countries)) {
             $country = NULL;
         }
     }
     // Is the currency valid
     if ($country && $module_config->allowed_currencies) {
         if (!in_array($country->currency, $module_config->allowed_currencies)) {
             $country = NULL;
         }
     }
     // set the locale
     if ($country && $country->getLocale()) {
         $this->config->setLocale($country->getLocale());
         $this->logger->info('Setting Locale: ' . $country->getLocale());
     }
 }
#!/usr/bin/env php
<?php 
// drop all tables in postgres database
//   drop schema public cascade;
//   create schema public;
use core\classes\Database;
use core\classes\Config;
use core\classes\Logger;
use core\classes\Model;
use core\classes\AutoLoader;
include 'core/ErrorHandler.php';
include 'core/Constants.php';
include 'core/classes/AutoLoader.php';
AutoLoader::init();
Logger::init();
$logger = Logger::getLogger('');
$config = new Config();
$database = new Database($config);
// get command line options
$longopts = ['domain:', 'scrapers:', 'methods:', 'no-commit'];
$options = getopt("", $longopts);
// make sure there is a domain
if (!isset($options['domain'])) {
    $logger->error('You must pass in a domain name');
    exit(1);
}
$config->setSiteDomain('www.' . $options['domain']);
$model = new Model($config, $database);
$exchange_rate = $model->getModel('\\modules\\exchange_rates\\classes\\models\\ExchangeRate');
$exchange_rate->updateRates();
 public function uninstall()
 {
     $model = new Model($this->config, $this->database);
     $table = $model->getModel('\\modules\\exchange_rates\\classes\\models\\ExchangeRate');
     $table->dropTable();
 }
 public function uninstall()
 {
     $model = new Model($this->config, $this->database);
     $table = $model->getModel('\\modules\\location_detect\\classes\\models\\CountryIP4');
     $table->dropTable();
 }
示例#6
0
 public function getExchangeRate()
 {
     $model = new Model($this->config, $this->database);
     $exchange_rate = $model->getModel('modules\\exchange_rates\\classes\\models\\ExchangeRate');
     return $exchange_rate->convert($this->config->siteConfig()->currency, 1);
 }