rendered paste body<?php// Do something with the directory and its subdirectories, recursive.// By Joshua Dickerson// The function you want to call (get_var, get_func, replace)$do_function = 'get_var';// The type of display (print_r, var_dump, echo)$display_type = 'print_r';// Replace spaces with tabs.$space_to_tabs = true;// Sort type (ksort, sort, none)$sort = 'sort';// Remove duplicates$unique = true;// Match the changes per file$per_file = false;// What to match in your regular expression$match = 'context';// An array of things to replace$replace = array( // From => To. 'include_once' => 'include', 'require_once' => 'require',);// Replace using a regex (still uses the $replace array)$replace_regex = false;// Use <pre>$pre = false;### STOP EDITING HERE ###scandir__recursive(dirname(__FILE__));output();function output(){ global $array, $unique, $space_to_tabs, $sort, $display_type; if ($unique) $array = array_unique($array); if ($sort == 'sort') sort($array); elseif($sort == 'ksort') ksort($array); ob_start(); if ($pre) echo '<pre>'; if ($display_type == 'print_r') print_r($array); elseif($display_type == 'var_dump') echo var_dump($array); elseif($display_type == 'echo') echo $array; if ($pre) echo '</pre>'; $contents = ob_get_contents(); if ($spaces_to_tabs) $contents = str_replace(' ', ' ', $contents); ob_end_clean(); echo $contents;}function scandir__recursive($dir){ global $array, $do_function, $return; $array = $return = array(); $opendir = scandir($dir); foreach ($opendir as $file) { $full_path = $dir . '/' . $file; // Current directory, parent directory, and .htaccess are not useful. if (substr($file, 0, 1) == '.' || $full_path == __FILE__) continue; // This is another directory. if (is_dir(str_replace('\\', '/', $full_path))) { $return[] = scandir__recursive($full_path); } else { $return[] = $file; $source = file_get_contents($full_path); $do_function($full_path, $source); } }}function loop_matches($matches){ global $array, $per_file; if (!empty($matches[1])) { foreach ($matches[1] as $key => $match) { if ($per_file) { if (!isset($array[$match])) $array[$match] = array(); if (!$unique || (isset($array[$match]) && !in_array($file, $array[$match]))) $array[$match][] = $file; } else $array[] = $match; } }}function get_var($full_path, $source){ global $match; //preg_match_all('/\$modSettings\[\'(.+?)\'\]/', $source, $matches); preg_match_all('/\$' . $match . '\[\'(.+?)\'\]/', $source, $matches); loop_matches($matches);}function get_func($full_path, $source){ global $match; preg_match_all('/' . $match . '\(\'(.+?)\'\)/', $source, $matches); loop_matches($matches);}function replace($full_path, $source){ global $replace, $replace_regex; if ($replace_regex) file_put_contents($full_path, preg_replace(array_keys($replace), array_values($replace), $source)); else file_put_contents($full_path, strtr($source, $replace));}?>