diff --git a/src/Calc/Calc.php b/src/Calc/Calc.php index 219cb6a..25d1a27 100644 --- a/src/Calc/Calc.php +++ b/src/Calc/Calc.php @@ -114,7 +114,11 @@ class Calc if($edge->getCalcValue() != "") { $cv = $this->formelCalc->parse($edge->getCalcValue()); - eval('$cv = ' . $cv . ';'); + try { + eval('@$cv = ' . $cv . ';'); + }catch (\Throwable $e) { + $cv = 0; + } $this->engine->addCalcVariable($option->getId() . '_' . $collection->getName(), $cv); $this->engine->setCalcVaribleStack($cv, $calcValueId); } @@ -180,4 +184,4 @@ class Calc return str_replace(',', '.', $value); } -} \ No newline at end of file +} diff --git a/src/Calc/CalcValues.php b/src/Calc/CalcValues.php index 4c01881..1b7833c 100644 --- a/src/Calc/CalcValues.php +++ b/src/Calc/CalcValues.php @@ -115,34 +115,47 @@ class CalcValues if ($edge->getCalcValue() != "") { $cv = $this->formelCalc->parse($edge->getCalcValue()); - eval('$cv = ' . $cv . ';'); - + try { + eval('@$cv = ' . $cv . ';'); + }catch (\Throwable $e) { + $cv = 0; + } + $this->engine->addCalcVariable($id, $cv); $this->engine->addCalcVariable($id . '_' . $collection->getName(), $cv); } if ($edge->getCalcValue1() != "") { $cv = $this->formelCalc->parse($edge->getCalcValue1()); - eval('$cv = ' . $cv . ';'); - //echo $id . ' '. $this->formelCalc->parse($edge->getCalcValue()) . ' ' . $cv . ' '. PHP_EOL.PHP_EOL; - + try { + eval('@$cv = ' . $cv . ';'); + }catch (\Throwable $e) { + $cv = 0; + } + $this->engine->addCalcVariable($id . '_1', $cv); $this->engine->addCalcVariable($id . '_' . $collection->getName() . '_1', $cv); } if ($edge->getCalcValue2() != "") { $cv = $this->formelCalc->parse($edge->getCalcValue2()); - eval('$cv = ' . $cv . ';'); - //echo $id . ' '. $this->formelCalc->parse($edge->getCalcValue()) . ' ' . $cv . ' '. PHP_EOL.PHP_EOL; - + try { + eval('@$cv = ' . $cv . ';'); + }catch (\Throwable $e) { + $cv = 0; + } + $this->engine->addCalcVariable($id . '_2', $cv); $this->engine->addCalcVariable($id . '_' . $collection->getName() . '_2', $cv); } if ($edge->getCalcValue3() != "") { $cv = $this->formelCalc->parse($edge->getCalcValue3()); - eval('$cv = ' . $cv . ';'); - //echo $id . ' '. $this->formelCalc->parse($edge->getCalcValue()) . ' ' . $cv . ' '. PHP_EOL.PHP_EOL; + try { + eval('@$cv = ' . $cv . ';'); + }catch (\Throwable $e) { + $cv = 0; + } $this->engine->addCalcVariable($id . '_3', $cv); @@ -150,8 +163,11 @@ class CalcValues } if ($edge->getCalcValue4() != "") { $cv = $this->formelCalc->parse($edge->getCalcValue4()); - eval('$cv = ' . $cv . ';'); - //echo $id . ' '. $this->formelCalc->parse($edge->getCalcValue()) . ' ' . $cv . ' '. PHP_EOL.PHP_EOL; + try { + eval('@$cv = ' . $cv . ';'); + }catch (\Throwable $e) { + $cv = 0; + } $this->engine->addCalcVariable($id . '_4', $cv); @@ -159,8 +175,11 @@ class CalcValues } if ($edge->getCalcValue5() != "") { $cv = $this->formelCalc->parse($edge->getCalcValue5()); - eval('$cv = ' . $cv . ';'); - //echo $id . ' '. $this->formelCalc->parse($edge->getCalcValue()) . ' ' . $cv . ' '. PHP_EOL.PHP_EOL; + try { + eval('@$cv = ' . $cv . ';'); + }catch (\Throwable $e) { + $cv = 0; + } $this->engine->addCalcVariable($id . '_5', $cv); @@ -168,8 +187,11 @@ class CalcValues } if ($edge->getCalcValue6() != "") { $cv = $this->formelCalc->parse($edge->getCalcValue6()); - eval('$cv = ' . $cv . ';'); - //echo $id . ' '. $this->formelCalc->parse($edge->getCalcValue()) . ' ' . $cv . ' '. PHP_EOL.PHP_EOL; + try { + eval('@$cv = ' . $cv . ';'); + }catch (\Throwable $e) { + $cv = 0; + } $this->engine->addCalcVariable($id . '_6', $cv); @@ -177,8 +199,11 @@ class CalcValues } if ($edge->getCalcValue7() != "") { $cv = $this->formelCalc->parse($edge->getCalcValue7()); - eval('$cv = ' . $cv . ';'); - //echo $id . ' '. $this->formelCalc->parse($edge->getCalcValue()) . ' ' . $cv . ' '. PHP_EOL.PHP_EOL; + try { + eval('@$cv = ' . $cv . ';'); + }catch (\Throwable $e) { + $cv = 0; + } $this->engine->addCalcVariable($id . '_7', $cv); @@ -186,8 +211,11 @@ class CalcValues } if ($edge->getCalcValue8() != "") { $cv = $this->formelCalc->parse($edge->getCalcValue8()); - eval('$cv = ' . $cv . ';'); - //echo $id . ' '. $this->formelCalc->parse($edge->getCalcValue()) . ' ' . $cv . ' '. PHP_EOL.PHP_EOL; + try { + eval('@$cv = ' . $cv . ';'); + }catch (\Throwable $e) { + $cv = 0; + } $this->engine->addCalcVariable($id . '_8', $cv); @@ -195,8 +223,11 @@ class CalcValues } if ($edge->getCalcValue9() != "") { $cv = $this->formelCalc->parse($edge->getCalcValue9()); - eval('$cv = ' . $cv . ';'); - //echo $id . ' '. $this->formelCalc->parse($edge->getCalcValue()) . ' ' . $cv . ' '. PHP_EOL.PHP_EOL; + try { + eval('@$cv = ' . $cv . ';'); + }catch (\Throwable $e) { + $cv = 0; + } $this->engine->addCalcVariable($id . '_9', $cv); @@ -204,8 +235,11 @@ class CalcValues } if ($edge->getCalcValue10() != "") { $cv = $this->formelCalc->parse($edge->getCalcValue10()); - eval('$cv = ' . $cv . ';'); - //echo $id . ' '. $this->formelCalc->parse($edge->getCalcValue()) . ' ' . $cv . ' '. PHP_EOL.PHP_EOL; + try { + eval('@$cv = ' . $cv . ';'); + }catch (\Throwable $e) { + $cv = 0; + } $this->engine->addCalcVariable($id . '_10', $cv);