<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } include_once PATH_THIRD . 'math/addon.setup.php'; $plugin_info = array('pi_author' => MATH_AUTHOR, 'pi_author_url' => MATH_AUTHOR_URL, 'pi_description' => MATH_DESC, 'pi_name' => MATH_NAME, 'pi_version' => MATH_VER, 'pi_usage' => Math::usage()); class Math { public $return_data = ''; public function __construct() { // Get formula $formula = ee()->TMPL->fetch_param('formula'); $error = false; $result = ''; if ($formula !== false) { // Convert html entities to math characters $formula = html_entity_decode($formula); // Replace parameters $params = ee()->TMPL->fetch_param('params'); $numeric_error = ee()->TMPL->fetch_param('numeric_error', 'Invalid input'); if ($params !== false) { $params = explode('|', $params); $i = 1; foreach ($params as $param) { if (!is_numeric($param)) { $param = preg_replace('/[^0-9.]*/', '', $param); if (!is_numeric($param)) { $this->return_data = $numeric_error; return;
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } $plugin_info = array('pi_name' => 'Math', 'pi_version' => '1.4.1', 'pi_author' => 'Caddis', 'pi_author_url' => 'http://www.caddis.co', 'pi_description' => 'Use Math to execute PHP supported math formulas.', 'pi_usage' => Math::usage()); class Math { public $return_data = ''; public function __construct() { // Get formula $formula = ee()->TMPL->fetch_param('formula'); $error = false; $result = ''; if ($formula !== false) { // Convert html entities to math characters $formula = html_entity_decode($formula); // Replace parameters $params = ee()->TMPL->fetch_param('params'); $numeric_error = ee()->TMPL->fetch_param('numeric_error', 'Invalid input'); if ($params !== false) { $params = explode('|', $params); $i = 1; foreach ($params as $param) { if (!is_numeric($param)) { $param = preg_replace('/[^0-9.]*/', '', $param); if (!is_numeric($param)) { $this->return_data = $numeric_error; return; }