All pastes #284280 Raw Edit

Something

public php v1 · immutable
#284280 ·published 2006-12-19 00:10 UTC
rendered paste body
	// Delete a directory recursively 	function rmdirr($dirname) {        // Sanity check        if (!file_exists($dirname)) {            return false;        }             // Simple delete for a file        if (is_file($dirname) || is_link($dirname)) {            return unlink($dirname);        }             // Loop through the folder        $dir = dir($dirname);        while (false !== $entry = $dir->read()) {            // Skip pointers            if ($entry == '.' || $entry == '..') {                continue;            }                 // Recurse            rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);        }             // Clean up        $dir->close();        return rmdir($dirname);    }    	// deletes the applicants directory    function delete_applicant_directory($applicant_id) {        global $BASE_PATH;        // I agree we should come up with a regexp to see what we are deleting.        $dirpath = $BASE_PATH . 'htdocs/media/applicants/' . hash_model_id($applicant_id) . '/';		if (is_dir($dirpath)) {		    return rmdirr($dirpath);		} else {		    return false;		}	}