| @@ 162-189 (lines=28) @@ | ||
| 159 | * |
|
| 160 | * @return bool true on success |
|
| 161 | */ |
|
| 162 | public static function planetParseFunction($function_string, $pattern = '', $replacement = '') |
|
| 163 | { |
|
| 164 | if (empty($function_string)) { |
|
| 165 | return; |
|
| 166 | } |
|
| 167 | $patterns = ["/\[DIRNAME\]/", "/\[VAR_PREFIX\]/"]; |
|
| 168 | $replacements = [$GLOBALS['moddirname'], $GLOBALS['VAR_PREFIX']]; |
|
| 169 | if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) { |
|
| 170 | $pattern = [$pattern]; |
|
| 171 | $replacement = [$replacement]; |
|
| 172 | } |
|
| 173 | if (is_array($pattern) && count($pattern) > 0) { |
|
| 174 | $ii = 0; |
|
| 175 | foreach ($pattern as $pat) { |
|
| 176 | if (!in_array($pat, $patterns)) { |
|
| 177 | $patterns[] = $pat; |
|
| 178 | $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : ''; |
|
| 179 | } |
|
| 180 | ++$ii; |
|
| 181 | } |
|
| 182 | } |
|
| 183 | $function_string = preg_replace($patterns, $replacements, $function_string); |
|
| 184 | if (is_array($function_string)) { |
|
| 185 | eval($function_string); |
|
| 186 | } |
|
| 187 | ||
| 188 | return true; |
|
| 189 | } |
|
| 190 | ||
| 191 | /** |
|
| 192 | * Function to convert UNIX time to formatted time string |
|
| @@ 155-180 (lines=26) @@ | ||
| 152 | * |
|
| 153 | * @return bool true on success |
|
| 154 | */ |
|
| 155 | function planetParseFunction($function_string, $pattern = '', $replacement = '') |
|
| 156 | { |
|
| 157 | if (empty($function_string)) { |
|
| 158 | return; |
|
| 159 | } |
|
| 160 | $patterns = ["/\[DIRNAME\]/", "/\[VAR_PREFIX\]/"]; |
|
| 161 | $replacements = [$GLOBALS['moddirname'], $GLOBALS['VAR_PREFIX']]; |
|
| 162 | if (!empty($pattern) && !is_array($pattern) && !is_array($replacement)) { |
|
| 163 | $pattern = [$pattern]; |
|
| 164 | $replacement = [$replacement]; |
|
| 165 | } |
|
| 166 | if (is_array($pattern) && count($pattern) > 0) { |
|
| 167 | $ii = 0; |
|
| 168 | foreach ($pattern as $pat) { |
|
| 169 | if (!in_array($pat, $patterns)) { |
|
| 170 | $patterns[] = $pat; |
|
| 171 | $replacements[] = isset($replacement[$ii]) ? $replacement[$ii] : ''; |
|
| 172 | } |
|
| 173 | ++$ii; |
|
| 174 | } |
|
| 175 | } |
|
| 176 | $function_string = preg_replace($patterns, $replacements, $function_string); |
|
| 177 | eval($function_string); |
|
| 178 | ||
| 179 | return true; |
|
| 180 | } |
|
| 181 | ||
| 182 | /** |
|
| 183 | * Function to convert UNIX time to formatted time string |
|