function formula_parseToPHP($formula, $detail) { global $FORMULA_SYMBOLS; $farmmalus = max($_SESSION['player']->fame - FREE_FARM_POINTS, 0); $formula = str_replace("[E25.ACT]", $farmmalus, $formula); if (Config::RUN_TIMER) { $timer = page_startTimer(); } // translate abstract functions to php functions $formula = str_replace(array('sgn'), array('SIGN'), $formula); // translate variables $php = ''; for ($i = 0; $i < strlen($formula); $i++) { if ($formula[$i] == '[') { $symbol = $formula[++$i]; $index = 0; while ($formula[++$i] != '.') { $index = $index * 10 + ($formula[$i] + 0); } $field = substr($formula, ++$i, 3); // 'ACT]' or 'MAX]' $i += 3; if (strncasecmp($field, "ACT", 3) == 0) { $php .= $detail . '["' . $FORMULA_SYMBOLS[$symbol][$index]->dbFieldName . '"]'; } else { if (strncasecmp($field, "MAX", 3) == 0) { $php .= formula_parseToPHP($FORMULA_SYMBOLS[$symbol][$index]->maxLevel, $detail); } } } else { $php .= $formula[$i]; } } if (Config::RUN_TIMER) { echo "<p>rules_parseToPHP: " . page_stopTimer($timer) . "s</p>"; } return $php; }
function page_stopTimer($time) { $newTime = page_startTimer(); return $newTime - $time; }