Code Duplication    Length = 26-26 lines in 2 locations

class/utility.php 1 location

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

include/functions.php 1 location

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