';
check_hooks($plugin_folder, $hook_function);
ksort($hook_function);
if($dryrun)
{
echo 'Possible functions found
';
echo '
'; print_r($hook_function); echo ''; echo "
'; print_r($edits); echo ''; echo "
"; print_r($split); echo ""; if(count($split) > 0) { $cleanhook = trim(trim(substr($split[0], 20, strlen($split[0])-21), "'"), '"'); $function = trim(trim(substr($split[1], 1, strlen($split[1])-3), "'"), '"'); $hook_function[$dir][$file][$function] = 'return'; } } } foreach($hooks_for_ref as $hook) { if(stristr($buffer, "add_hook") && (stristr($buffer, '"'.$hook.'"') || stristr($buffer, "'".$hook."'"))) { $split = preg_split("/[\s]*[,][\s]*/i", $buffer); if(count($split) > 0) { $cleanhook = trim(trim(substr($split[0], 20, strlen($split[0])-21), "'"), '"'); $function = trim(trim(substr($split[1], 1, strlen($split[1])-5), "'"), '"'); $hook_function[$dir][$file][$function] = 'ref'; } } } } fclose($filehandle); } } else { //recurse into directories if(is_dir($dir.'/'.$file)) { check_hooks($dir.'/'.$file, $hook_function); } } } } closedir($handle); } } function check_functions($hook_function, &$edits) { global $dryrun; if(count($hook_function) > 0) { foreach($hook_function as $dir=>$files) { foreach($files as $filename=>$functions) { $searches = array(); $replaces = array(); foreach($functions as $function_name=>$type) { $searches[] = "/function ".$function_name."[ ]*\([ ]*\\\$/i"; $replaces[] = "function ".$function_name."(&$"; } $edits[$dir.'/'.$filename] = array($searches, $replaces); } } } else { echo "Nothing to search"; } } function fix_files($edits) { global $dryrun; if(count($edits) > 0) { foreach($edits as $file=>$updates) { if($dryrun) { echo "Looking in ".$file.'
'; print_r($updates); echo ''; } $orig_text = file_get_contents($file); $modified = false; //foreach($updates as $update) { echo $search."