/home/hplex/live/wp-content/themes/lexicon/lib/Currency/Converter.php
if ($source == 'USD') {
$rate = $rates[$dest];
} else {
$rate = $rates[$dest] * (1 / $rates[$source]);
}
return $amount * $rate;
}
private function filesystem()
{
$adapter = new LocalFilesystemAdapter('/home/hplex/api/cache');
$filesystem = new Filesystem($adapter);
return $filesystem;
}
private function exchangeRateService()
{
$client = new Client();
return new OpenExchangeRatesService(
'3524ded9f850465799b082abb523ccad',
[
'https' => true,
'base_currency' => 'USD',
],
$client
);
}
public function getCurrencies()
{
$filesystem = $this->filesystem();
$currencyFile = 'currencies.json';
if (!$filesystem->fileExists($currencyFile) || time() - $filesystem->lastModified($currencyFile) >= 86400 * 30) {
return $this->fetchCurrencies();
}
Arguments
"Class "GuzzleHttp\Client" not found"
/home/hplex/live/wp-content/themes/lexicon/lib/Currency/Converter.php
$filename = $date->format("Y/m/d/") . "currencyRates-" . $date->format("Ymd").".json";
if (!$filesystem->fileExists($filename)) {
return $this->fetchHistoricalExchangeRates($date);
}
$rates = json_decode($filesystem->read($filename), true);
return $this->addWizardingExchangeRates($rates, $date);
}
private function fetchHistoricalExchangeRates(Carbon $date)
{
$earliest = new Carbon('1999-01-01');
if ($date->lt($earliest)) {
return [];
}
$service = $this->exchangeRateService();
$baseRates = $service->getHistorical($date);
$rates = $baseRates['rates'];
$filename = $date->format("Y/m/d/") . "currencyRates-" . $date->format("Ymd").".json";
$rates = $this->addWizardingExchangeRates($rates, $date);
$this->cacheExchangeRates($filename, $rates, $date);
return $rates;
}
private function addWizardingExchangeRates($rates, Carbon $date = null)
{
$rates['WZG'] = $rates['GBP'] / 5;
$rates['WZS'] = 17 * $rates['WZG'];
$rates['WZK'] = 29 * $rates['WZS'];
$rates['WZD'] = 1.5;
if (!empty($rates['XAU'])) {
/home/hplex/live/wp-content/themes/lexicon/lib/Currency/Converter.php
{
$filesystem = $this->filesystem();
if (!$date) {
$filesystem->write($file, json_encode($rates));
$date = new Carbon();
}
$filename = $date->format("Y/m/d/") . "currencyRates-" . $date->format("Ymd").".json";
$filesystem->write($filename, json_encode($rates));
}
public function getHistoricalExchangeRates(Carbon $date)
{
$filesystem = $this->filesystem();
$filename = $date->format("Y/m/d/") . "currencyRates-" . $date->format("Ymd").".json";
if (!$filesystem->fileExists($filename)) {
return $this->fetchHistoricalExchangeRates($date);
}
$rates = json_decode($filesystem->read($filename), true);
return $this->addWizardingExchangeRates($rates, $date);
}
private function fetchHistoricalExchangeRates(Carbon $date)
{
$earliest = new Carbon('1999-01-01');
if ($date->lt($earliest)) {
return [];
}
$service = $this->exchangeRateService();
$baseRates = $service->getHistorical($date);
$rates = $baseRates['rates'];
$filename = $date->format("Y/m/d/") . "currencyRates-" . $date->format("Ymd").".json";
/home/hplex/live/wp-content/themes/lexicon/lib/Currency/Converter.php
if ($date) {
$rates = $this->getHistoricalExchangeRates($date);
} else {
$rates = $this->getCurrentExchangeRates();
}
$conversion = $this->convertCurrency($conversion, $rates, 'GBP', $currency);
}
$totalGalleons = $galleons + ($sickles / $this->sicklesToGalleons) + ($knuts / $this->knutsToGalleons);
return number_format((ceil($totalGalleons * $conversion * 100) / 100), 2);
}
public function wizardToMuggleAll($galleons, $sickels, $knuts, $date = null, $selectedCurrencies = [])
{
if ($date) {
$date = $this->checkDate($date);
}
if ($date) {
$rates = $this->getHistoricalExchangeRates($date);
} else {
$rates = $this->getCurrentExchangeRates();
}
$currencies = $this->getCurrencies();
$currencies['FRF'] = 'French Francs';
$currencies['DEM'] = 'German Marks';
$currencies['ITL'] = 'Italian Lira';
$currencies['ESP'] = 'Spanish Pesetas';
$converted = [];
$totalGalleons = $galleons + ($sickels / $this->sicklesToGalleons) + ($knuts / $this->knutsToGalleons);
foreach ($rates as $currency => $rate) {
if ($currency == 'GBP') {
$conversion = 5;
} else {
$conversion = $this->convertCurrency(5, $rates, 'GBP', $currency);
}
/home/hplex/live/wp-content/themes/lexicon/single-event.php
* @package WordPress
* @subpackage Timber
* @since Timber 0.1
*/
$data = Timber::get_context();
$data['type'] = $data['type_info'] = $data['post']->type();
$data['iconbanners'] = $data['post']->iconBanners();
$data['icons'] = $data['post']->icons();
$visibleCurrencies = commonCurrencies();
if (isset($data['post']->year) && $data['post']->date_type == 'full') {
$data['hplex_datetime'] = $date = new Carbon($data['post']->hplex_datetime());
if ($date->gte(new Carbon('1971-01-01')) && $date->lte(new Carbon())) {
$converter = new Converter();
$data['currency_rates'] = $converter->wizardToMuggleAll(1, 0, 0, $date, $visibleCurrencies);
}
}
if (isset($_REQUEST['debug']) && $_REQUEST['debug'] == 'breakthisnick') {
dump($data['hplex_datetime']);
dump($data['currency_rates']);
dd($data);
}
if (post_password_required($data['post']->ID)) {
Timber::render('single-password.twig', $data);
} else {
Timber::render(array( 'single-' . $data['post']->ID . '.twig', 'single-' . $data['post']->post_type . '.twig', 'single.twig' ), $data);
}
/home/hplex/live/www/wp-includes/template-loader.php
*/
$template = apply_filters( 'template_include', $template );
$is_stringy = is_string( $template ) || ( is_object( $template ) && method_exists( $template, '__toString' ) );
$template = $is_stringy ? realpath( (string) $template ) : null;
if (
is_string( $template ) &&
( str_ends_with( $template, '.php' ) || str_ends_with( $template, '.html' ) ) &&
is_file( $template ) &&
is_readable( $template )
) {
/**
* Fires immediately before including the template.
*
* @since 6.9.0
*
* @param string $template The path of the template about to be included.
*/
do_action( 'wp_before_include_template', $template );
include $template;
} elseif ( current_user_can( 'switch_themes' ) ) {
$theme = wp_get_theme();
if ( $theme->errors() ) {
wp_die( $theme->errors() );
}
}
return;
}
Arguments
"/home/hplex/live/wp-content/themes/lexicon/single-event.php"
/home/hplex/live/www/wp-blog-header.php
<?php
/**
* Loads the WordPress environment and template.
*
* @package WordPress
*/
if ( ! isset( $wp_did_header ) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once __DIR__ . '/wp-load.php';
// Set up the WordPress query.
wp();
// Load the theme template.
require_once ABSPATH . WPINC . '/template-loader.php';
}
Arguments
"/home/hplex/live/www/wp-includes/template-loader.php"
/home/hplex/live/www/index.php
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define( 'WP_USE_THEMES', true );
/** Loads the WordPress Environment and Template */
require __DIR__ . '/wp-blog-header.php';
Arguments
"/home/hplex/live/www/wp-blog-header.php"