/**
 * recursively retrieves all the revisions of the file.
 * recurses DOWN the revisions path.
 * PRIVATE! use fs_get_revisions() above.
 */
function fs_get_revisions_down_recursive($file_id) {
	global $db;

	if ($file_id == 0) {
		return array();
	}

	$sql = "SELECT * FROM ".TABLE_PREFIX."files WHERE file_id=$file_id";
	$result = mysql_query($sql, $db);
	$row = mysql_fetch_assoc($result);

	if (!$row) {
		return array();
	} else if (!$row['parent_file_id']) {
		return array($row);
	}

	return array_merge(array($row), fs_get_revisions_down_recursive($row['parent_file_id']));
}
/**
 * recursively retrieves all the revisions of the file.
 * recurses DOWN the revisions path.
 * PRIVATE! use fs_get_revisions() above.
 */
function fs_get_revisions_down_recursive($file_id)
{
    if ($file_id == 0) {
        return array();
    }
    $sql = "SELECT * FROM %sfiles WHERE file_id=%d";
    $row = queryDB($sql, array(TABLE_PREFIX, $file_id), TRUE);
    if (!isset($row)) {
        return array();
    } else {
        if (!isset($row['parent_file_id'])) {
            return array($row);
        }
    }
    return array_merge(array($row), fs_get_revisions_down_recursive($row['parent_file_id']));
}