All pastes #74650 Raw Edit

Anonymous

public text v1 · immutable
#74650 ·published 2006-06-29 08:23 UTC
rendered paste body
<?php
$depth = 0;
fix_folder('./phpro.org/*', $depth);
function fix_folder($folder, $depth) {
    foreach(glob($folder) as $filename) {
        if(substr($filename, strrpos($filename, '.')) == "html") {
            fix_html($filename, str_repeat("../", $depth));
        }
        if(is_dir($filename)) {
            fix_folder($filename.'/*', $depth+1);
        }
    }
}

function fix_html($filename, $append) {
    $file = file_get_contents($filename);
    $file = str_replace('href="/', 'href="'.$append, $file);
    $file = str_replace('src="/', 'src="'.$append, $file);
    file_put_contents($filename, $file);
}